v0.15.5
Loading...
Searching...
No Matches
Classes | Public Member Functions | Private Member Functions | Private Attributes | List of all members
SetUpSchurImpl Struct Reference
Inheritance diagram for SetUpSchurImpl:
[legend]
Collaboration diagram for SetUpSchurImpl:
[legend]

Classes

struct  P_MultiGridData
 

Public Member Functions

 SetUpSchurImpl (MoFEM::Interface &m_field)
 
virtual ~SetUpSchurImpl ()=default
 
MoFEMErrorCode setUp (SmartPetscObj< KSP >)
 
 SetUpSchurImpl (MoFEM::Interface &m_field, SmartPetscObj< DM > sub_dm, SmartPetscObj< IS > field_split_is, SmartPetscObj< AO > ao_up)
 
virtual ~SetUpSchurImpl ()
 
MoFEMErrorCode setUp (TS solver)
 
MoFEMErrorCode preProc ()
 
MoFEMErrorCode postProc ()
 
 SetUpSchurImpl (MoFEM::Interface &m_field)
 
virtual ~SetUpSchurImpl ()
 
MoFEMErrorCode setUp (SmartPetscObj< TS > solver)
 
 SetUpSchurImpl (MoFEM::Interface &m_field)
 
virtual ~SetUpSchurImpl ()
 
MoFEMErrorCode setUp (SmartPetscObj< TS > solver)
 
 SetUpSchurImpl (MoFEM::Interface &m_field)
 
virtual ~SetUpSchurImpl ()=default
 
MoFEMErrorCode setUp (SmartPetscObj< KSP > solver)
 
 SetUpSchurImpl (MoFEM::Interface &m_field, EshelbianCore *ep_core_ptr)
 
virtual ~SetUpSchurImpl ()
 
MoFEMErrorCode setUp (TS ts)
 
MoFEMErrorCode preProc ()
 
MoFEMErrorCode postProc ()
 
 SetUpSchurImpl (MoFEM::Interface &m_field, SmartPetscObj< DM > sub_dm, SmartPetscObj< IS > field_split_is, SmartPetscObj< AO > ao_up)
 
virtual ~SetUpSchurImpl ()
 
MoFEMErrorCode setUp (TS solver)
 
MoFEMErrorCode preProc ()
 
MoFEMErrorCode postProc ()
 
 SetUpSchurImpl (MoFEM::Interface &m_field, SmartPetscObj< DM > sub_dm, SmartPetscObj< IS > field_split_is, SmartPetscObj< AO > ao_up)
 
virtual ~SetUpSchurImpl ()
 
MoFEMErrorCode setUp (TS solver)
 
MoFEMErrorCode preProc ()
 
MoFEMErrorCode postProc ()
 
 SetUpSchurImpl (MoFEM::Interface &m_field)
 
virtual ~SetUpSchurImpl ()
 
MoFEMErrorCode setUp (SmartPetscObj< TS > solver)
 
 SetUpSchurImpl (MoFEM::Interface &m_field)
 
virtual ~SetUpSchurImpl ()=default
 
MoFEMErrorCode setUp (SmartPetscObj< KSP > solver)
 

Private Member Functions

MoFEMErrorCode createSubDM ()
 
MoFEMErrorCode setOperator ()
 
MoFEMErrorCode setPC (PC pc)
 
MoFEMErrorCode setDiagonalPC (PC pc)
 
MoFEMErrorCode setOperator ()
 
MoFEMErrorCode setPC (PC pc)
 
SmartPetscObj< DM > createSubDM ()
 
MoFEMErrorCode setEntities ()
 
MoFEMErrorCode createSubDM ()
 
MoFEMErrorCode setOperator ()
 
MoFEMErrorCode setPC (PC pc)
 
MoFEMErrorCode setDiagonalPC (PC pc)
 
auto getSchurFields ()
 
auto getA00Fields ()
 
MoFEMErrorCode createSubDM ()
 
MoFEMErrorCode setOperator ()
 
MoFEMErrorCode setPC (PC pc)
 
MoFEMErrorCode setDiagonalPC (PC pc)
 
MoFEMErrorCode setEntities ()
 
MoFEMErrorCode createSubDM ()
 
MoFEMErrorCode setOperator ()
 
MoFEMErrorCode setPC (PC pc)
 
MoFEMErrorCode setDiagonalPC (PC pc)
 

Private Attributes

MoFEM::InterfacemField
 
SmartPetscObj< Mat > S
 
SmartPetscObj< DM > subDM
 field split sub dm
 
SmartPetscObj< IS > fieldSplitIS
 IS for split Schur block.
 
SmartPetscObj< AO > aoSchur
 
SmartPetscObj< DM > schurDM
 
SmartPetscObj< DM > blockDM
 
Range volEnts
 
Range subEnts
 
EshelbianCoreepCorePtr
 
SmartPetscObj< AO > aoS
 
boost::shared_ptr< std::vector< boost::weak_ptr< NumeredDofEntity > > > piolaZeroDofsVec
 
boost::shared_ptr< std::vector< unsigned char > > piolaZeroDofsMarker
 
boost::shared_ptr< P_MultiGridDatapMGPtr
 

Additional Inherited Members

- Static Public Member Functions inherited from SetUpSchur
static boost::shared_ptr< SetUpSchurcreateSetUpSchur (MoFEM::Interface &m_field)
 
static boost::shared_ptr< SetUpSchurcreateSetUpSchur (MoFEM::Interface &m_field, SmartPetscObj< DM > sub_dm, SmartPetscObj< IS > field_split_it, SmartPetscObj< AO > ao_map)
 Create data structure for handling Schur complement.
 
static boost::shared_ptr< SetUpSchurcreateSetUpSchur (MoFEM::Interface &m_field)
 
static boost::shared_ptr< SetUpSchurcreateSetUpSchur (MoFEM::Interface &m_field)
 
static boost::shared_ptr< SetUpSchurcreateSetUpSchur (MoFEM::Interface &m_field)
 
static boost::shared_ptr< SetUpSchurcreateSetUpSchur (MoFEM::Interface &m_field, SmartPetscObj< DM > sub_dm, SmartPetscObj< IS > field_split_it, SmartPetscObj< AO > ao_map)
 Create data structure for handling Schur complement.
 
static boost::shared_ptr< SetUpSchurcreateSetUpSchur (MoFEM::Interface &m_field, SmartPetscObj< DM > sub_dm, SmartPetscObj< IS > field_split_it, SmartPetscObj< AO > ao_map)
 Create data structure for handling Schur complement.
 
static boost::shared_ptr< SetUpSchurcreateSetUpSchur (MoFEM::Interface &m_field)
 
static boost::shared_ptr< SetUpSchurcreateSetUpSchur (MoFEM::Interface &m_field)
 
- Static Public Member Functions inherited from EshelbianCore::SetUpSchur
static boost::shared_ptr< SetUpSchurcreateSetUpSchur (MoFEM::Interface &m_field, EshelbianCore *ep_core_ptr)
 
- Protected Member Functions inherited from SetUpSchur
 SetUpSchur ()=default
 
virtual ~SetUpSchur ()=default
 
 SetUpSchur ()=default
 
 SetUpSchur ()=default
 
 SetUpSchur ()=default
 
 SetUpSchur ()=default
 
 SetUpSchur ()=default
 
 SetUpSchur ()=default
 
 SetUpSchur ()=default
 
 SetUpSchur ()=default
 
- Protected Member Functions inherited from EshelbianCore::SetUpSchur
 SetUpSchur ()=default
 

Detailed Description

Examples
mofem/atom_tests/test_broken_space.cpp, mofem/tutorials/adv-0_plasticity/plastic.cpp, mofem/tutorials/vec-10_elasticity_schur/schur_elastic.cpp, plastic.cpp, and thermoplastic.cpp.

Definition at line 543 of file test_broken_space.cpp.

Constructor & Destructor Documentation

◆ SetUpSchurImpl() [1/10]

SetUpSchurImpl::SetUpSchurImpl ( MoFEM::Interface m_field)
inline

Definition at line 545 of file test_broken_space.cpp.

545: SetUpSchur(), mField(m_field) {}
MoFEM::Interface & mField
SetUpSchur()=default

◆ ~SetUpSchurImpl() [1/10]

virtual SetUpSchurImpl::~SetUpSchurImpl ( )
virtualdefault

◆ SetUpSchurImpl() [2/10]

SetUpSchurImpl::SetUpSchurImpl ( MoFEM::Interface m_field,
SmartPetscObj< DM >  sub_dm,
SmartPetscObj< IS >  field_split_is,
SmartPetscObj< AO >  ao_up 
)
inline

Definition at line 1665 of file plastic.cpp.

1667 : SetUpSchur(), mField(m_field), subDM(sub_dm),
1668 fieldSplitIS(field_split_is), aoSchur(ao_up) {
1669 if (S) {
1671 "Is expected that schur matrix is not "
1672 "allocated. This is "
1673 "possible only is if PC is set up twice");
1674 }
1675 }
#define CHK_THROW_MESSAGE(err, msg)
Check and throw MoFEM exception.
@ MOFEM_DATA_INCONSISTENCY
Definition definitions.h:31
SmartPetscObj< DM > subDM
field split sub dm
Definition plastic.cpp:1686
SmartPetscObj< Mat > S
SmartPetscObj< AO > aoSchur
Definition plastic.cpp:1688
SmartPetscObj< IS > fieldSplitIS
IS for split Schur block.
Definition plastic.cpp:1687

◆ ~SetUpSchurImpl() [2/10]

virtual SetUpSchurImpl::~SetUpSchurImpl ( )
inlinevirtual

Definition at line 1676 of file plastic.cpp.

1676{ S.reset(); }

◆ SetUpSchurImpl() [3/10]

SetUpSchurImpl::SetUpSchurImpl ( MoFEM::Interface m_field)
inline

Definition at line 1010 of file contact.cpp.

1010: SetUpSchur(), mField(m_field) {}

◆ ~SetUpSchurImpl() [3/10]

virtual SetUpSchurImpl::~SetUpSchurImpl ( )
inlinevirtual

Definition at line 1012 of file contact.cpp.

1012{}

◆ SetUpSchurImpl() [4/10]

SetUpSchurImpl::SetUpSchurImpl ( MoFEM::Interface m_field)
inline

Definition at line 990 of file incompressible_elasticity.cpp.

990: SetUpSchur(), mField(m_field) {}

◆ ~SetUpSchurImpl() [4/10]

virtual SetUpSchurImpl::~SetUpSchurImpl ( )
inlinevirtual

Definition at line 991 of file incompressible_elasticity.cpp.

991{ S.reset(); }

◆ SetUpSchurImpl() [5/10]

SetUpSchurImpl::SetUpSchurImpl ( MoFEM::Interface m_field)
inline

Definition at line 178 of file schur_elastic.cpp.

178 : SetUpSchur(), mField(m_field) {
179 if (S) {
182 "Is expected that schur matrix is not allocated. This is "
183 "possible only is if PC is set up twice");
184 }
185 }

◆ ~SetUpSchurImpl() [5/10]

virtual SetUpSchurImpl::~SetUpSchurImpl ( )
virtualdefault

◆ SetUpSchurImpl() [6/10]

SetUpSchurImpl::SetUpSchurImpl ( MoFEM::Interface m_field,
EshelbianCore ep_core_ptr 
)
inline

Definition at line 11 of file SetUpSchurImpl.cpp.

12 : SetUpSchur(), mField(m_field), epCorePtr(ep_core_ptr) {}
EshelbianCore * epCorePtr

◆ ~SetUpSchurImpl() [6/10]

virtual SetUpSchurImpl::~SetUpSchurImpl ( )
inlinevirtual

Definition at line 13 of file SetUpSchurImpl.cpp.

13{}

◆ SetUpSchurImpl() [7/10]

SetUpSchurImpl::SetUpSchurImpl ( MoFEM::Interface m_field,
SmartPetscObj< DM >  sub_dm,
SmartPetscObj< IS >  field_split_is,
SmartPetscObj< AO >  ao_up 
)
inline

Definition at line 5783 of file thermoplastic.cpp.

5785 : SetUpSchur(), mField(m_field), subDM(sub_dm),
5786 fieldSplitIS(field_split_is), aoSchur(ao_up) {
5787 if (S) {
5789 "Is expected that schur matrix is not "
5790 "allocated. This is "
5791 "possible only is PC is set up twice");
5792 }
5793 }

◆ ~SetUpSchurImpl() [7/10]

virtual SetUpSchurImpl::~SetUpSchurImpl ( )
inlinevirtual

Definition at line 5794 of file thermoplastic.cpp.

5794{ S.reset(); }

◆ SetUpSchurImpl() [8/10]

SetUpSchurImpl::SetUpSchurImpl ( MoFEM::Interface m_field,
SmartPetscObj< DM >  sub_dm,
SmartPetscObj< IS >  field_split_is,
SmartPetscObj< AO >  ao_up 
)
inline

Definition at line 1655 of file plastic.cpp.

1657 : SetUpSchur(), mField(m_field), subDM(sub_dm),
1658 fieldSplitIS(field_split_is), aoSchur(ao_up) {
1659 if (S) {
1661 "Is expected that schur matrix is not "
1662 "allocated. This is "
1663 "possible only is PC is set up twice");
1664 }
1665 }

◆ ~SetUpSchurImpl() [8/10]

virtual SetUpSchurImpl::~SetUpSchurImpl ( )
inlinevirtual

Definition at line 1666 of file plastic.cpp.

1666{ S.reset(); }

◆ SetUpSchurImpl() [9/10]

SetUpSchurImpl::SetUpSchurImpl ( MoFEM::Interface m_field)
inline

Definition at line 1018 of file contact.cpp.

1018: SetUpSchur(), mField(m_field) {}

◆ ~SetUpSchurImpl() [9/10]

virtual SetUpSchurImpl::~SetUpSchurImpl ( )
inlinevirtual

Definition at line 1020 of file contact.cpp.

1020{}

◆ SetUpSchurImpl() [10/10]

SetUpSchurImpl::SetUpSchurImpl ( MoFEM::Interface m_field)
inline

Definition at line 756 of file elastic.cpp.

756 : SetUpSchur(), mField(m_field) {
757 if (S) {
760 "Is expected that schur matrix is not allocated. This is "
761 "possible only is PC is set up twice");
762 }
763 }

◆ ~SetUpSchurImpl() [10/10]

virtual SetUpSchurImpl::~SetUpSchurImpl ( )
virtualdefault

Member Function Documentation

◆ createSubDM() [1/5]

MoFEMErrorCode SetUpSchurImpl::createSubDM ( )
private
Examples
mofem/tutorials/vec-10_elasticity_schur/schur_elastic.cpp.

Definition at line 1104 of file contact.cpp.

1104 {
1106 auto simple = mField.getInterface<Simple>();
1107
1108 auto create_dm = [&](const char *name, const char *field_name, auto dm_type) {
1109 auto dm = createDM(mField.get_comm(), dm_type);
1110 auto create_dm_imp = [&]() {
1112 CHKERR DMMoFEMCreateSubDM(dm, simple->getDM(), name);
1113 CHKERR DMMoFEMSetSquareProblem(dm, PETSC_TRUE);
1114 CHKERR DMMoFEMAddElement(dm, simple->getDomainFEName());
1117 CHKERR DMSetUp(dm);
1119 };
1121 create_dm_imp(),
1122 "Error in creating schurDM. It is possible that schurDM is "
1123 "already created");
1124 return dm;
1125 };
1126
1127 // Note: here we can make block with bubbles of "U" and "SIGMA" fields. See
1128 // vec-0_elasticity where bubbles are added.
1129
1130 schurDM = create_dm("SCHUR", "U", "DMMOFEM_MG");
1131 blockDM = create_dm("BLOCK", "SIGMA", "DMMOFEM");
1132
1133 if constexpr (AT == AssemblyType::BLOCK_SCHUR) {
1134
1135 auto get_nested_mat_data = [&](auto schur_dm, auto block_dm) {
1136 auto block_mat_data = createBlockMatStructure(
1137 simple->getDM(),
1138
1139 {{
1140
1141 simple->getDomainFEName(),
1142
1143 {
1144
1145 {"U", "U"}, {"SIGMA", "U"}, {"U", "SIGMA"}, {"SIGMA", "SIGMA"}
1146
1147 }}}
1148
1149 );
1150
1152
1153 {schur_dm, block_dm}, block_mat_data,
1154
1155 {"SIGMA"}, {nullptr}, true
1156
1157 );
1158 };
1159
1160 auto nested_mat_data = get_nested_mat_data(schurDM, blockDM);
1161 CHKERR DMMoFEMSetNestSchurData(simple->getDM(), nested_mat_data);
1162
1163 } else {
1164 SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED,
1165 "Only BLOCK_SCHUR is implemented");
1166 }
1167
1169}
void simple(double P1[], double P2[], double P3[], double c[], const int N)
Definition acoustic.cpp:69
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
@ MOFEM_NOT_IMPLEMENTED
Definition definitions.h:32
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define CHKERR
Inline error check.
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 DMMoFEMAddSubFieldRow(DM dm, const char field_name[])
Definition DMMoFEM.cpp:238
PetscErrorCode DMMoFEMAddSubFieldCol(DM dm, const char field_name[])
Definition DMMoFEM.cpp:280
boost::shared_ptr< BlockStructure > createBlockMatStructure(DM dm, SchurFEOpsFEandFields schur_fe_op_vec)
Create a Mat Diag Blocks object.
Definition Schur.cpp:1082
boost::shared_ptr< NestSchurData > createSchurNestedMatrixStruture(std::pair< SmartPetscObj< DM >, SmartPetscObj< DM > > dms, boost::shared_ptr< BlockStructure > block_mat_data_ptr, std::vector< std::string > fields_names, std::vector< boost::shared_ptr< Range > > field_ents, bool add_preconditioner_block)
Get the Schur Nest Mat Array object.
Definition Schur.cpp:2421
MoFEMErrorCode DMMoFEMSetNestSchurData(DM dm, boost::shared_ptr< NestSchurData >)
Definition DMMoFEM.cpp:1554
auto createDM(MPI_Comm comm, const std::string dm_type_name)
Creates smart DM object.
constexpr auto field_name
virtual MPI_Comm & get_comm() const =0
Simple interface for fast problem set-up.
Definition Simple.hpp:27
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.
SmartPetscObj< DM > schurDM
Definition contact.cpp:1025
SmartPetscObj< DM > blockDM
Definition contact.cpp:1026
constexpr AssemblyType AT

◆ createSubDM() [2/5]

SmartPetscObj< DM > SetUpSchurImpl::createSubDM ( )
private

◆ createSubDM() [3/5]

MoFEMErrorCode SetUpSchurImpl::createSubDM ( )
private

◆ createSubDM() [4/5]

MoFEMErrorCode SetUpSchurImpl::createSubDM ( )
private

◆ createSubDM() [5/5]

MoFEMErrorCode SetUpSchurImpl::createSubDM ( )
private

◆ getA00Fields()

auto SetUpSchurImpl::getA00Fields ( )
inlineprivate

Definition at line 60 of file SetUpSchurImpl.cpp.

60 {
61 std::vector<std::string> a00_field_list{
62
64
66
68
70
72
73 };
74 std::vector<boost::shared_ptr<Range>> range_list_ptr(a00_field_list.size(),
75 nullptr);
76 return std::make_pair(a00_field_list, range_list_ptr);
77 }
const std::string spatialL2Disp
const std::string piolaStress
const std::string bubbleField
const std::string rotAxis
const std::string stretchTensor

◆ getSchurFields()

auto SetUpSchurImpl::getSchurFields ( )
inlineprivate

Definition at line 53 of file SetUpSchurImpl.cpp.

53 {
54 std::vector<std::string> schur_field_list{epCorePtr->hybridSpatialDisp,
56 std::vector<boost::shared_ptr<Range>> dm_range_list{nullptr, nullptr};
57 return std::make_pair(schur_field_list, dm_range_list);
58 };
const std::string contactDisp
const std::string hybridSpatialDisp

◆ postProc() [1/4]

MoFEMErrorCode SetUpSchurImpl::postProc ( )

◆ postProc() [2/4]

MoFEMErrorCode SetUpSchurImpl::postProc ( )

◆ postProc() [3/4]

MoFEMErrorCode SetUpSchurImpl::postProc ( )

◆ postProc() [4/4]

MoFEMErrorCode SetUpSchurImpl::postProc ( )

◆ preProc() [1/4]

MoFEMErrorCode SetUpSchurImpl::preProc ( )

◆ preProc() [2/4]

MoFEMErrorCode SetUpSchurImpl::preProc ( )

◆ preProc() [3/4]

MoFEMErrorCode SetUpSchurImpl::preProc ( )

◆ preProc() [4/4]

MoFEMErrorCode SetUpSchurImpl::preProc ( )

◆ setDiagonalPC() [1/4]

MoFEMErrorCode SetUpSchurImpl::setDiagonalPC ( PC  pc)
private
Examples
mofem/tutorials/vec-10_elasticity_schur/schur_elastic.cpp.

Definition at line 1254 of file contact.cpp.

1254 {
1256 KSP *subksp;
1257 CHKERR PCFieldSplitSchurGetSubKSP(pc, PETSC_NULLPTR, &subksp);
1258 auto get_pc = [](auto ksp) {
1259 PC pc_raw;
1260 CHKERR KSPGetPC(ksp, &pc_raw);
1261 return SmartPetscObj<PC>(pc_raw, true); // bump reference
1262 };
1263 CHKERR setSchurA00MatSolvePC(get_pc(subksp[0]));
1264
1265 auto set_pc_p_mg = [](auto dm, auto pc, auto S) {
1267 CHKERR PCSetDM(pc, dm);
1268 PetscBool same = PETSC_FALSE;
1269 PetscObjectTypeCompare((PetscObject)pc, PCMG, &same);
1270 if (same) {
1272 pc, createPCMGSetUpViaApproxOrdersCtx(dm, S, true));
1273 CHKERR PCSetFromOptions(pc);
1274 }
1276 };
1277
1278 auto set_pc_ksp = [&](auto dm, auto pc, auto S) {
1280 PetscBool same = PETSC_FALSE;
1281 PetscObjectTypeCompare((PetscObject)pc, PCKSP, &same);
1282 if (same) {
1283 CHKERR PCSetFromOptions(pc);
1284 KSP inner_ksp;
1285 CHKERR PCKSPGetKSP(pc, &inner_ksp);
1286 CHKERR KSPSetFromOptions(inner_ksp);
1287 PC inner_pc;
1288 CHKERR KSPGetPC(inner_ksp, &inner_pc);
1289 CHKERR PCSetFromOptions(inner_pc);
1290 CHKERR set_pc_p_mg(dm, inner_pc, S);
1291 }
1293 };
1294
1295 CHKERR set_pc_ksp(schurDM, get_pc(subksp[1]), S);
1296 CHKERR set_pc_p_mg(schurDM, get_pc(subksp[1]), S);
1297
1298 CHKERR PetscFree(subksp);
1300}
MoFEMErrorCode setSchurA00MatSolvePC(SmartPetscObj< PC > pc)
Set PC for A00 block.
Definition Schur.cpp:2705
boost::shared_ptr< PCMGSetUpViaApproxOrdersCtx > createPCMGSetUpViaApproxOrdersCtx(DM dm, Mat A, bool use_shell_mat)
createPCMGSetUpViaApproxOrdersCtx
MoFEMErrorCode PCMGSetUpViaApproxOrders(PC pc, boost::shared_ptr< PCMGSetUpViaApproxOrdersCtx > ctx, int verb)
Function build MG structure.
intrusive_ptr for managing petsc objects

◆ setDiagonalPC() [2/4]

MoFEMErrorCode SetUpSchurImpl::setDiagonalPC ( PC  pc)
private

◆ setDiagonalPC() [3/4]

MoFEMErrorCode SetUpSchurImpl::setDiagonalPC ( PC  pc)
private

◆ setDiagonalPC() [4/4]

MoFEMErrorCode SetUpSchurImpl::setDiagonalPC ( PC  pc)
private

◆ setEntities() [1/2]

MoFEMErrorCode SetUpSchurImpl::setEntities ( )
private
Examples
mofem/tutorials/vec-10_elasticity_schur/schur_elastic.cpp.

Definition at line 251 of file schur_elastic.cpp.

251 {
254 CHKERR mField.get_moab().get_entities_by_dimension(simple->getMeshset(),
256 CHKERR mField.get_moab().get_entities_by_handle(simple->getMeshset(),
257 subEnts);
258 subEnts = subtract(subEnts, volEnts);
260};
virtual moab::Interface & get_moab()=0
constexpr int SPACE_DIM
[Define dimension]
Definition elastic.cpp:18

◆ setEntities() [2/2]

MoFEMErrorCode SetUpSchurImpl::setEntities ( )
private

◆ setOperator() [1/5]

MoFEMErrorCode SetUpSchurImpl::setOperator ( )
private
Examples
mofem/tutorials/vec-10_elasticity_schur/schur_elastic.cpp.

Definition at line 1171 of file contact.cpp.

1171 {
1173
1174 double eps_stab = 1e-4;
1175 CHKERR PetscOptionsGetScalar(PETSC_NULLPTR, "", "-eps_stab", &eps_stab,
1176 PETSC_NULLPTR);
1177
1180 using OpMassStab = B::OpMass<3, SPACE_DIM * SPACE_DIM>;
1181
1182 auto simple = mField.getInterface<Simple>();
1183 auto pip = mField.getInterface<PipelineManager>();
1184
1185 auto dm_is = getDMSubData(schurDM)->getSmartRowIs();
1186 auto ao_up = createAOMappingIS(dm_is, PETSC_NULLPTR);
1187
1188 // Boundary
1189 pip->getOpBoundaryLhsPipeline().push_front(createOpSchurAssembleBegin());
1190 pip->getOpBoundaryLhsPipeline().push_back(
1191 new OpMassStab("SIGMA", "SIGMA",
1192 [eps_stab](double, double, double) { return eps_stab; }));
1193 pip->getOpBoundaryLhsPipeline().push_back(
1194
1195 createOpSchurAssembleEnd({"SIGMA"}, {nullptr}, ao_up, S, false, false)
1196
1197 );
1198
1199 // Domain
1200 pip->getOpDomainLhsPipeline().push_front(createOpSchurAssembleBegin());
1201 pip->getOpDomainLhsPipeline().push_back(
1202
1203 createOpSchurAssembleEnd({"SIGMA"}, {nullptr}, ao_up, S, false, false)
1204
1205 );
1206
1207 auto pre_proc_schur_lhs_ptr = boost::make_shared<FEMethod>();
1208 auto post_proc_schur_lhs_ptr = boost::make_shared<FEMethod>();
1209
1210 pre_proc_schur_lhs_ptr->preProcessHook = [this]() {
1212 CHKERR MatZeroEntries(S);
1213 MOFEM_LOG("CONTACT", Sev::verbose) << "Lhs Assemble Begin";
1215 };
1216
1217 post_proc_schur_lhs_ptr->postProcessHook = [this, ao_up,
1218 post_proc_schur_lhs_ptr]() {
1220 MOFEM_LOG("CONTACT", Sev::verbose) << "Lhs Assemble End";
1221 auto print_mat_norm = [this](auto a, std::string prefix) {
1223 double nrm;
1224 CHKERR MatNorm(a, NORM_FROBENIUS, &nrm);
1225 MOFEM_LOG("CONTACT", Sev::noisy) << prefix << " norm = " << nrm;
1227 };
1228 CHKERR MatAssemblyBegin(S, MAT_FINAL_ASSEMBLY);
1229 CHKERR MatAssemblyEnd(S, MAT_FINAL_ASSEMBLY);
1231 mField, post_proc_schur_lhs_ptr, 1, S, ao_up)();
1232#ifndef NDEBUG
1233 CHKERR print_mat_norm(S, "S");
1234#endif // NDEBUG
1235 MOFEM_LOG("CONTACT", Sev::verbose) << "Lhs Assemble Finish";
1237 };
1238
1239 auto ts_ctx_ptr = getDMTsCtx(simple->getDM());
1240 ts_ctx_ptr->getPreProcessIJacobian().push_front(pre_proc_schur_lhs_ptr);
1241 ts_ctx_ptr->getPostProcessIJacobian().push_back(post_proc_schur_lhs_ptr);
1242
1244}
constexpr double a
@ BLOCK_PRECONDITIONER_SCHUR
Block preconditioner Schur assembly.
#define MOFEM_LOG(channel, severity)
Log.
auto getDMTsCtx(DM dm)
Get TS context data structure used by DM.
Definition DMMoFEM.hpp:1276
OpSchurAssembleBase * createOpSchurAssembleEnd(std::vector< std::string > fields_name, std::vector< boost::shared_ptr< Range > > field_ents, SmartPetscObj< AO > ao, SmartPetscObj< Mat > schur, bool sym_schur, bool symm_op)
Construct a new Op Schur Assemble End object.
Definition Schur.cpp:2663
PetscErrorCode PetscOptionsGetScalar(PetscOptions *, const char pre[], const char name[], PetscScalar *dval, PetscBool *set)
auto getDMSubData(DM dm)
Get sub problem data structure.
Definition DMMoFEM.hpp:1292
auto createAOMappingIS(IS isapp, IS ispetsc)
Creates an application mapping using two index sets.
OpSchurAssembleBase * createOpSchurAssembleBegin()
Definition Schur.cpp:2658
Class (Function) to enforce essential constrains on the left hand side diagonal.
Definition Essential.hpp:33
PipelineManager interface.

◆ setOperator() [2/5]

MoFEMErrorCode SetUpSchurImpl::setOperator ( )
private

◆ setOperator() [3/5]

MoFEMErrorCode SetUpSchurImpl::setOperator ( )
private

◆ setOperator() [4/5]

MoFEMErrorCode SetUpSchurImpl::setOperator ( )
private

◆ setOperator() [5/5]

MoFEMErrorCode SetUpSchurImpl::setOperator ( )
private

◆ setPC() [1/5]

MoFEMErrorCode SetUpSchurImpl::setPC ( PC  pc)
private
Examples
mofem/tutorials/vec-10_elasticity_schur/schur_elastic.cpp.

Definition at line 1246 of file contact.cpp.

1246 {
1248 auto block_is = getDMSubData(blockDM)->getSmartRowIs();
1249 CHKERR PCFieldSplitSetIS(pc, NULL, block_is);
1250 CHKERR PCFieldSplitSetSchurPre(pc, PC_FIELDSPLIT_SCHUR_PRE_USER, S);
1252}

◆ setPC() [2/5]

MoFEMErrorCode SetUpSchurImpl::setPC ( PC  pc)
private

◆ setPC() [3/5]

MoFEMErrorCode SetUpSchurImpl::setPC ( PC  pc)
private

◆ setPC() [4/5]

MoFEMErrorCode SetUpSchurImpl::setPC ( PC  pc)
private

◆ setPC() [5/5]

MoFEMErrorCode SetUpSchurImpl::setPC ( PC  pc)
private

◆ setUp() [1/10]

MoFEMErrorCode SetUpSchurImpl::setUp ( SmartPetscObj< KSP >  solver)
virtual

Implements SetUpSchur.

◆ setUp() [2/10]

MoFEMErrorCode SetUpSchurImpl::setUp ( SmartPetscObj< KSP >  solver)
virtual

Implements SetUpSchur.

◆ setUp() [3/10]

MoFEMErrorCode SetUpSchurImpl::setUp ( SmartPetscObj< KSP >  ksp)
virtual

Implements SetUpSchur.

Examples
mofem/atom_tests/test_broken_space.cpp, mofem/tutorials/adv-0_plasticity/plastic.cpp, mofem/tutorials/vec-10_elasticity_schur/schur_elastic.cpp, plastic.cpp, and thermoplastic.cpp.

Definition at line 556 of file test_broken_space.cpp.

556 {
559 auto pip_mng = mField.getInterface<PipelineManager>();
560
561 CHKERR KSPSetFromOptions(ksp);
562 PC pc;
563 CHKERR KSPGetPC(ksp, &pc);
564
565 PetscBool is_pcfs = PETSC_FALSE;
566 PetscObjectTypeCompare((PetscObject)pc, PCFIELDSPLIT, &is_pcfs);
567 if (is_pcfs) {
568
569 MOFEM_LOG("AT", Sev::inform) << "Setup Schur pc";
570
571 auto create_sub_dm = [&]() {
573
574 auto create_dm = [&](
575
576 std::string problem_name,
577 std::vector<std::string> fe_names,
578 std::vector<std::string> fields,
579
580 auto dm_type
581
582 ) {
583 auto dm = createDM(mField.get_comm(), dm_type);
584 auto create_dm_imp = [&]() {
586 CHKERR DMMoFEMCreateSubDM(dm, simple->getDM(), problem_name.c_str());
587 CHKERR DMMoFEMSetSquareProblem(dm, PETSC_TRUE);
588 for (auto fe : fe_names) {
590 }
591 CHKERR DMMoFEMAddElement(dm, simple->getSkeletonFEName());
592 for (auto field : fields) {
593 CHKERR DMMoFEMAddSubFieldRow(dm, field);
594 CHKERR DMMoFEMAddSubFieldCol(dm, field);
595 }
596 CHKERR DMSetUp(dm);
598 };
600 create_dm_imp(),
601 "Error in creating schurDM. It is possible that schurDM is "
602 "already created");
603 return dm;
604 };
605
606 auto schur_dm = create_dm(
607
608 "SCHUR",
609
610 {simple->getDomainFEName(), simple->getSkeletonFEName()},
611
612 {"HYBRID"},
613
614 "DMMOFEM_MG");
615
616 auto block_dm = create_dm(
617
618 "BLOCK",
619
620 {simple->getDomainFEName(), simple->getSkeletonFEName()},
621
622 {"BROKEN", "U"},
623
624 "DMMOFEM");
625
626 return std::make_tuple(schur_dm, block_dm);
627 };
628
629 auto get_nested_mat_data = [&](auto schur_dm, auto block_dm) {
630 auto block_mat_data = createBlockMatStructure(
631 simple->getDM(),
632
633 {
634
635 {
636
637 simple->getDomainFEName(),
638
639 {
640
641 {"BROKEN", "BROKEN"},
642 {"U", "U"},
643 {"BROKEN", "U"},
644 {"U", "BROKEN"}
645
646 }
647
648 },
649
650 {
651
652 simple->getSkeletonFEName(),
653
654 {
655
656 {"BROKEN", "HYBRID"}, {"HYBRID", "BROKEN"}
657
658 }
659
660 }
661
662 }
663
664 );
665
667
668 {schur_dm, block_dm}, block_mat_data,
669
670 {"BROKEN", "U"}, {nullptr, nullptr}, true
671
672 );
673 };
674
675 auto set_ops = [&](auto schur_dm) {
677 auto dm_is = getDMSubData(schur_dm)->getSmartRowIs();
678 auto ao_up = createAOMappingIS(dm_is, PETSC_NULLPTR);
679
680 boost::shared_ptr<BlockStructure> block_data;
681 CHKERR DMMoFEMGetBlocMatData(simple->getDM(), block_data);
682
683 if (AT == BLOCK_SCHUR) {
684 pip_mng->getOpDomainLhsPipeline().push_front(
686 pip_mng->getOpDomainLhsPipeline().push_back(
687
688 createOpSchurAssembleEnd({"BROKEN", "U"}, {nullptr, nullptr}, ao_up,
689 S, true, true)
690
691 );
692 }
693
694 auto pre_proc_schur_lhs_ptr = boost::make_shared<FEMethod>();
695 auto post_proc_schur_lhs_ptr = boost::make_shared<FEMethod>();
696
697 pre_proc_schur_lhs_ptr->preProcessHook = [this]() {
699 CHKERR MatZeroEntries(S);
700 MOFEM_LOG("AT", Sev::verbose) << "Lhs Assemble Begin";
702 };
703
704 post_proc_schur_lhs_ptr->postProcessHook = [this, ao_up,
705 post_proc_schur_lhs_ptr]() {
707 MOFEM_LOG("AT", Sev::verbose) << "Lhs Assemble End";
708
709 if (AT == BLOCK_SCHUR) {
710 CHKERR MatAssemblyBegin(S, MAT_FINAL_ASSEMBLY);
711 CHKERR MatAssemblyEnd(S, MAT_FINAL_ASSEMBLY);
712 if (1) {
713 auto S_from_block = matDuplicate(S, MAT_SHARE_NONZERO_PATTERN);
714 // Create matrix from block mat
715 CHKERR assembleBlockMatSchur(mField, post_proc_schur_lhs_ptr->B,
716 S_from_block, {"BROKEN", "U"},
717 {nullptr, nullptr}, ao_up);
718 CHKERR MatAssemblyBegin(S_from_block, MAT_FINAL_ASSEMBLY);
719 CHKERR MatAssemblyEnd(S_from_block, MAT_FINAL_ASSEMBLY);
720 CHKERR MatAYPX(S_from_block, -1, S, DIFFERENT_NONZERO_PATTERN);
721 double norm;
722 CHKERR MatNorm(S_from_block, NORM_FROBENIUS, &norm);
723 MOFEM_LOG("AT", Sev::inform) << "Norm of difference: " << norm;
724 if (norm > 1e-6)
725 SETERRQ(
726 PETSC_COMM_SELF, MOFEM_ATOM_TEST_INVALID,
727 "Norm of difference between Schur and block matrix is larger "
728 "than accepted");
729 }
730 } else {
731 CHKERR assembleBlockMatSchur(mField, post_proc_schur_lhs_ptr->B, S,
732 {"BROKEN", "U"}, {nullptr, nullptr}, ao_up);
733 CHKERR MatAssemblyBegin(S, MAT_FINAL_ASSEMBLY);
734 CHKERR MatAssemblyEnd(S, MAT_FINAL_ASSEMBLY);
735 }
736
737 MOFEM_LOG("AT", Sev::verbose) << "Lhs Assemble Finish";
739 };
740
741 auto ksp_ctx_ptr = getDMKspCtx(simple->getDM());
742 ksp_ctx_ptr->getPreProcSetOperators().push_front(pre_proc_schur_lhs_ptr);
743 ksp_ctx_ptr->getPostProcSetOperators().push_back(post_proc_schur_lhs_ptr);
744
746 };
747
748 auto set_pc = [&](auto pc, auto block_dm) {
750 auto block_is = getDMSubData(block_dm)->getSmartRowIs();
751 CHKERR PCFieldSplitSetIS(pc, NULL, block_is);
752 CHKERR PCFieldSplitSetSchurPre(pc, PC_FIELDSPLIT_SCHUR_PRE_USER, S);
754 };
755
756
757
758 auto [schur_dm, block_dm] = create_sub_dm();
759 if (AT == BLOCK_SCHUR || AT == BLOCK_MAT) {
760 auto nested_mat_data = get_nested_mat_data(schur_dm, block_dm);
761 CHKERR DMMoFEMSetNestSchurData(simple->getDM(), nested_mat_data);
762 }
763 S = createDMHybridisedL2Matrix(schur_dm);
764 CHKERR MatSetDM(S, PETSC_NULLPTR);
765
766 int bs = (SPACE_DIM == 2) ? NBEDGE_L2(approx_order - 1)
768 CHKERR MatSetBlockSize(S, bs);
769
770 CHKERR set_ops(schur_dm);
771 CHKERR set_pc(pc, block_dm);
772 DM solver_dm;
773 CHKERR KSPGetDM(ksp, &solver_dm);
774 if (AT == BLOCK_SCHUR || AT == BLOCK_MAT)
775 CHKERR DMSetMatType(solver_dm, MATSHELL);
776
777 auto get_pc = [](auto ksp) {
778 PC pc_raw;
779 CHKERR KSPGetPC(ksp, &pc_raw);
780 return pc_raw;
781 };
782
783 auto set_diagonal_pc = [&](auto pc) {
785
786 if (AT == BLOCK_SCHUR || AT == BLOCK_MAT) {
787 auto A = createDMBlockMat(simple->getDM());
788 auto P = createDMNestSchurMat(simple->getDM());
789 CHKERR PCSetOperators(pc, A, P);
790 }
791
792 KSP *subksp;
793 CHKERR PCFieldSplitSchurGetSubKSP(pc, PETSC_NULLPTR, &subksp);
794 CHKERR setSchurA00MatSolvePC(SmartPetscObj<PC>(get_pc(subksp[0]), true));
795
796 CHKERR PetscFree(subksp);
798 };
799
800 auto set_mg_for_schur_complement = [&](auto pc, auto schur_dm, auto S) {
802
803 KSP *subksp;
804 CHKERR PCFieldSplitSchurGetSubKSP(pc, PETSC_NULLPTR, &subksp);
805 auto subpc = get_pc(subksp[1]);
806
807 auto set_pc_p_mg = [](auto dm, auto pc, auto S) {
809 CHKERR PCSetDM(pc, dm);
810 PetscBool same = PETSC_FALSE;
811 PetscObjectTypeCompare((PetscObject)pc, PCMG, &same);
812 if (same) {
813 MOFEM_LOG("TIMER", Sev::inform) << "Set up MG";
815 pc, createPCMGSetUpViaApproxOrdersCtx(dm, S, true));
816 CHKERR PCSetFromOptions(pc);
817 }
819 };
820
821 PetscBool same = PETSC_FALSE;
822 PetscObjectTypeCompare((PetscObject)subpc, PCKSP, &same);
823 if (same) {
824 CHKERR PCSetFromOptions(subpc);
825 KSP inner_ksp;
826 CHKERR PCKSPGetKSP(subpc, &inner_ksp);
827 CHKERR KSPSetFromOptions(inner_ksp);
828 PC inner_pc;
829 CHKERR KSPGetPC(inner_ksp, &inner_pc);
830 CHKERR PCSetFromOptions(inner_pc);
831 CHKERR set_pc_p_mg(schur_dm, inner_pc, S);
832 }
833
834 CHKERR PetscFree(subksp);
836 };
837
838 CHKERR KSPSetUp(ksp);
839 if (AT == BLOCK_SCHUR || AT == BLOCK_MAT) {
840 CHKERR set_diagonal_pc(pc);
841 CHKERR set_mg_for_schur_complement(pc, schur_dm, S);
842 }
843
844 } else {
845 SETERRQ(PETSC_COMM_SELF, MOFEM_ATOM_TEST_INVALID,
846 "PC is not set to PCFIELDSPLIT");
847 }
849}
@ MOFEM_ATOM_TEST_INVALID
Definition definitions.h:40
@ BLOCK_MAT
Block matrix assembly.
@ BLOCK_SCHUR
Block Schur assembly.
#define NBFACETRI_L2(P)
Number of base functions on triangle for L2 space.
#define NBEDGE_L2(P)
Number of base functions on edge from L2 space.
MoFEMErrorCode DMMoFEMGetBlocMatData(DM dm, boost::shared_ptr< BlockStructure > &)
Get data for block mat.
Definition DMMoFEM.cpp:1534
auto getDMKspCtx(DM dm)
Get KSP context data structure used by DM.
Definition DMMoFEM.hpp:1248
auto createDMHybridisedL2Matrix(DM dm)
Get smart hybridised L2 matrix from DM.
Definition DMMoFEM.hpp:1204
SmartPetscObj< Mat > matDuplicate(Mat mat, MatDuplicateOption op)
auto createDMNestSchurMat(DM dm)
Definition DMMoFEM.hpp:1218
MoFEMErrorCode assembleBlockMatSchur(MoFEM::Interface &m_field, Mat B, Mat S, std::vector< std::string > fields_name, std::vector< boost::shared_ptr< Range > > field_ents, SmartPetscObj< AO > ao)
Assemble Schur matrix.
Definition Schur.cpp:1895
auto createDMBlockMat(DM dm)
Definition DMMoFEM.hpp:1211
static constexpr int approx_order
constexpr AssemblyType A
[Define dimension]
Definition elastic.cpp:21

◆ setUp() [4/10]

MoFEMErrorCode SetUpSchurImpl::setUp ( SmartPetscObj< TS >  solver)
virtual

Implements SetUpSchur.

Definition at line 1029 of file contact.cpp.

1029 {
1031 auto simple = mField.getInterface<Simple>();
1032 auto pip = mField.getInterface<PipelineManager>();
1033
1034 SNES snes;
1035 CHKERR TSGetSNES(solver, &snes);
1036 KSP ksp;
1037 CHKERR SNESGetKSP(snes, &ksp);
1038 CHKERR KSPSetFromOptions(ksp);
1039
1040 PC pc;
1041 CHKERR KSPGetPC(ksp, &pc);
1042
1043 PetscBool is_pcfs = PETSC_FALSE;
1044 PetscObjectTypeCompare((PetscObject)pc, PCFIELDSPLIT, &is_pcfs);
1045 if (is_pcfs) {
1046
1047 MOFEM_LOG("CONTACT", Sev::inform) << "Setup Schur pc";
1048
1049 if (S) {
1052 "It is expected that Schur matrix is not allocated. This is "
1053 "possible only if PC is set up twice");
1054 }
1055
1057
1058 // Add data to DM storage
1060 CHKERR MatSetBlockSize(S, SPACE_DIM);
1061 // CHKERR MatSetOption(S, MAT_SYMMETRIC, PETSC_TRUE);
1062
1063 // Set DM to use shell block matrix
1064 DM solver_dm;
1065 CHKERR TSGetDM(solver, &solver_dm);
1066 CHKERR DMSetMatType(solver_dm, MATSHELL);
1067
1068 auto ts_ctx_ptr = getDMTsCtx(solver_dm);
1069 auto A = createDMBlockMat(simple->getDM());
1070 auto P = createDMNestSchurMat(simple->getDM());
1071
1072 if (is_quasi_static == PETSC_TRUE) {
1073 auto swap_assemble = [](TS ts, PetscReal t, Vec u, Vec u_t, PetscReal a,
1074 Mat A, Mat B, void *ctx) {
1075 return TsSetIJacobian(ts, t, u, u_t, a, B, A, ctx);
1076 };
1077 CHKERR TSSetIJacobian(solver, A, P, swap_assemble, ts_ctx_ptr.get());
1078 } else {
1079 auto swap_assemble = [](TS ts, PetscReal t, Vec u, Vec u_t, Vec utt,
1080 PetscReal a, PetscReal aa, Mat A, Mat B,
1081 void *ctx) {
1082 return TsSetI2Jacobian(ts, t, u, u_t, utt, a, aa, B, A, ctx);
1083 };
1084 CHKERR TSSetI2Jacobian(solver, A, P, swap_assemble, ts_ctx_ptr.get());
1085 }
1086 CHKERR KSPSetOperators(ksp, A, P);
1087
1089 CHKERR setPC(pc);
1090 CHKERR TSSetUp(solver);
1091 CHKERR KSPSetUp(ksp);
1093
1094 } else {
1095 MOFEM_LOG("CONTACT", Sev::inform) << "No Schur PC";
1096 pip->getOpBoundaryLhsPipeline().push_front(createOpSchurAssembleBegin());
1097 pip->getOpBoundaryLhsPipeline().push_back(createOpSchurAssembleEnd({}, {}));
1098 pip->getOpDomainLhsPipeline().push_front(createOpSchurAssembleBegin());
1099 pip->getOpDomainLhsPipeline().push_back(createOpSchurAssembleEnd({}, {}));
1100 }
1102}
auto createDMMatrix(DM dm)
Get smart matrix from DM.
Definition DMMoFEM.hpp:1191
const FTensor::Tensor2< T, Dim, Dim > Vec
PetscErrorCode TsSetIJacobian(TS ts, PetscReal t, Vec u, Vec u_t, PetscReal a, Mat A, Mat B, void *ctx)
Set function evaluating jacobian in TS solver.
Definition TsCtx.cpp:169
PetscErrorCode TsSetI2Jacobian(TS ts, PetscReal t, Vec u, Vec u_t, Vec u_tt, PetscReal a, PetscReal aa, Mat A, Mat B, void *ctx)
Calculation Jacobian for second order PDE in time.
Definition TsCtx.cpp:519
constexpr double t
plate stiffness
Definition plate.cpp:58
MoFEMErrorCode createSubDM()
Definition contact.cpp:1104
MoFEMErrorCode setDiagonalPC(PC pc)
Definition contact.cpp:1254
MoFEMErrorCode setPC(PC pc)
Definition contact.cpp:1246
MoFEMErrorCode setOperator()
Definition contact.cpp:1171
PetscBool is_quasi_static
Definition plastic.cpp:143

◆ setUp() [5/10]

MoFEMErrorCode SetUpSchurImpl::setUp ( SmartPetscObj< TS >  solver)
virtual

Implements SetUpSchur.

◆ setUp() [6/10]

MoFEMErrorCode SetUpSchurImpl::setUp ( SmartPetscObj< TS >  solver)
virtual

Implements SetUpSchur.

◆ setUp() [7/10]

MoFEMErrorCode SetUpSchurImpl::setUp ( TS  solver)
virtual

Implements SetUpSchur.

Definition at line 1691 of file plastic.cpp.

1691 {
1693 auto simple = mField.getInterface<Simple>();
1694 auto pip_mng = mField.getInterface<PipelineManager>();
1695
1696 SNES snes;
1697 CHKERR TSGetSNES(solver, &snes);
1698 KSP ksp;
1699 CHKERR SNESGetKSP(snes, &ksp);
1700 CHKERR KSPSetFromOptions(ksp);
1701
1702 PC pc;
1703 CHKERR KSPGetPC(ksp, &pc);
1704 PetscBool is_pcfs = PETSC_FALSE;
1705 PetscObjectTypeCompare((PetscObject)pc, PCFIELDSPLIT, &is_pcfs);
1706 if (is_pcfs) {
1707 if (S) {
1709 "Is expected that schur matrix is not "
1710 "allocated. This is "
1711 "possible only is if PC is set up twice");
1712 }
1713
1715 CHKERR MatSetBlockSize(S, SPACE_DIM);
1716
1717 // Set DM to use shell block matrix
1718 DM solver_dm;
1719 CHKERR TSGetDM(solver, &solver_dm);
1720 CHKERR DMSetMatType(solver_dm, MATSHELL);
1721
1722 auto ts_ctx_ptr = getDMTsCtx(solver_dm);
1723 auto A = createDMBlockMat(simple->getDM());
1724 auto P = createDMNestSchurMat(simple->getDM());
1725
1726 if (is_quasi_static == PETSC_TRUE) {
1727 auto swap_assemble = [](TS ts, PetscReal t, Vec u, Vec u_t, PetscReal a,
1728 Mat A, Mat B, void *ctx) {
1729 return TsSetIJacobian(ts, t, u, u_t, a, B, A, ctx);
1730 };
1731 CHKERR TSSetIJacobian(solver, A, P, swap_assemble, ts_ctx_ptr.get());
1732 } else {
1733 auto swap_assemble = [](TS ts, PetscReal t, Vec u, Vec u_t, Vec utt,
1734 PetscReal a, PetscReal aa, Mat A, Mat B,
1735 void *ctx) {
1736 return TsSetI2Jacobian(ts, t, u, u_t, utt, a, aa, B, A, ctx);
1737 };
1738 CHKERR TSSetI2Jacobian(solver, A, P, swap_assemble, ts_ctx_ptr.get());
1739 }
1740 CHKERR KSPSetOperators(ksp, A, P);
1741
1742 auto set_ops = [&]() {
1744 auto pip_mng = mField.getInterface<PipelineManager>();
1745
1746#ifndef ADD_CONTACT
1747 // Boundary
1748 pip_mng->getOpBoundaryLhsPipeline().push_front(
1750 pip_mng->getOpBoundaryLhsPipeline().push_back(createOpSchurAssembleEnd(
1751
1752 {"EP", "TAU"}, {nullptr, nullptr}, aoSchur, S, false, false
1753
1754 ));
1755 // Domain
1756 pip_mng->getOpDomainLhsPipeline().push_front(
1758 pip_mng->getOpDomainLhsPipeline().push_back(createOpSchurAssembleEnd(
1759
1760 {"EP", "TAU"}, {nullptr, nullptr}, aoSchur, S, false, false
1761
1762 ));
1763#else
1764
1765 double eps_stab = 1e-4;
1766 CHKERR PetscOptionsGetScalar(PETSC_NULLPTR, "", "-eps_stab", &eps_stab,
1767 PETSC_NULLPTR);
1768
1771 using OpMassStab = B::OpMass<3, SPACE_DIM * SPACE_DIM>;
1772
1773 // Boundary
1774 pip_mng->getOpBoundaryLhsPipeline().push_front(
1776 pip_mng->getOpBoundaryLhsPipeline().push_back(
1777 new OpMassStab("SIGMA", "SIGMA", [eps_stab](double, double, double) {
1778 return eps_stab;
1779 }));
1780 pip_mng->getOpBoundaryLhsPipeline().push_back(createOpSchurAssembleEnd(
1781
1782 {"SIGMA", "EP", "TAU"}, {nullptr, nullptr, nullptr}, aoSchur, S,
1783 false, false
1784
1785 ));
1786 // Domain
1787 pip_mng->getOpDomainLhsPipeline().push_front(
1789 pip_mng->getOpDomainLhsPipeline().push_back(createOpSchurAssembleEnd(
1790
1791 {"SIGMA", "EP", "TAU"}, {nullptr, nullptr, nullptr}, aoSchur, S,
1792 false, false
1793
1794 ));
1795#endif // ADD_CONTACT
1797 };
1798
1799 auto set_assemble_elems = [&]() {
1801 auto schur_asmb_pre_proc = boost::make_shared<FEMethod>();
1802 schur_asmb_pre_proc->preProcessHook = [this]() {
1804 CHKERR MatZeroEntries(S);
1805 MOFEM_LOG("TIMER", Sev::verbose) << "Lhs Assemble Begin";
1807 };
1808 auto schur_asmb_post_proc = boost::make_shared<FEMethod>();
1809
1810 schur_asmb_post_proc->postProcessHook = [this, schur_asmb_post_proc]() {
1812 MOFEM_LOG("TIMER", Sev::verbose) << "Lhs Assemble End";
1813
1814 // Apply essential constrains to Schur complement
1815 CHKERR MatAssemblyBegin(S, MAT_FINAL_ASSEMBLY);
1816 CHKERR MatAssemblyEnd(S, MAT_FINAL_ASSEMBLY);
1818 mField, schur_asmb_post_proc, 1, S, aoSchur)();
1819
1821 };
1822 auto ts_ctx_ptr = getDMTsCtx(simple->getDM());
1823 ts_ctx_ptr->getPreProcessIJacobian().push_front(schur_asmb_pre_proc);
1824 ts_ctx_ptr->getPostProcessIJacobian().push_front(schur_asmb_post_proc);
1826 };
1827
1828 auto set_pc = [&]() {
1830 CHKERR PCFieldSplitSetIS(pc, NULL, fieldSplitIS);
1831 CHKERR PCFieldSplitSetSchurPre(pc, PC_FIELDSPLIT_SCHUR_PRE_USER, S);
1833 };
1834
1835 auto set_diagonal_pc = [&]() {
1837 KSP *subksp;
1838 CHKERR PCFieldSplitSchurGetSubKSP(pc, PETSC_NULLPTR, &subksp);
1839 auto get_pc = [](auto ksp) {
1840 PC pc_raw;
1841 CHKERR KSPGetPC(ksp, &pc_raw);
1842 return SmartPetscObj<PC>(pc_raw,
1843 true); // bump reference
1844 };
1845 CHKERR setSchurA00MatSolvePC(get_pc(subksp[0]));
1846 CHKERR PetscFree(subksp);
1848 };
1849
1850 CHKERR set_ops();
1851 CHKERR set_pc();
1852 CHKERR set_assemble_elems();
1853
1854 CHKERR TSSetUp(solver);
1855 CHKERR KSPSetUp(ksp);
1856 CHKERR set_diagonal_pc();
1857
1858 } else {
1859 pip_mng->getOpBoundaryLhsPipeline().push_front(
1861 pip_mng->getOpBoundaryLhsPipeline().push_back(
1862 createOpSchurAssembleEnd({}, {}));
1863 pip_mng->getOpDomainLhsPipeline().push_front(createOpSchurAssembleBegin());
1864 pip_mng->getOpDomainLhsPipeline().push_back(
1865 createOpSchurAssembleEnd({}, {}));
1866 }
1867
1868 // fieldSplitIS.reset();
1869 // aoSchur.reset();
1871}

◆ setUp() [8/10]

MoFEMErrorCode SetUpSchurImpl::setUp ( TS  solver)
virtual

Implements SetUpSchur.

◆ setUp() [9/10]

MoFEMErrorCode SetUpSchurImpl::setUp ( TS  solver)
virtual

Implements SetUpSchur.

◆ setUp() [10/10]

MoFEMErrorCode SetUpSchurImpl::setUp ( TS  ts)
virtual

Implements SetUpSchur.

Member Data Documentation

◆ aoS

SmartPetscObj<AO> SetUpSchurImpl::aoS
private

Definition at line 24 of file SetUpSchurImpl.cpp.

◆ aoSchur

SmartPetscObj< AO > SetUpSchurImpl::aoSchur
private

◆ blockDM

SmartPetscObj< DM > SetUpSchurImpl::blockDM
private

◆ epCorePtr

EshelbianCore* SetUpSchurImpl::epCorePtr
private

Definition at line 21 of file SetUpSchurImpl.cpp.

◆ fieldSplitIS

SmartPetscObj< IS > SetUpSchurImpl::fieldSplitIS
private

IS for split Schur block.

Examples
mofem/tutorials/adv-0_plasticity/plastic.cpp, plastic.cpp, and thermoplastic.cpp.

Definition at line 1687 of file plastic.cpp.

◆ mField

MoFEM::Interface & SetUpSchurImpl::mField
private

◆ piolaZeroDofsMarker

boost::shared_ptr<std::vector<unsigned char> > SetUpSchurImpl::piolaZeroDofsMarker
private

Definition at line 29 of file SetUpSchurImpl.cpp.

◆ piolaZeroDofsVec

boost::shared_ptr<std::vector<boost::weak_ptr<NumeredDofEntity> > > SetUpSchurImpl::piolaZeroDofsVec
private

Definition at line 27 of file SetUpSchurImpl.cpp.

◆ pMGPtr

boost::shared_ptr<P_MultiGridData> SetUpSchurImpl::pMGPtr
private

Definition at line 51 of file SetUpSchurImpl.cpp.

◆ S

SmartPetscObj< Mat > SetUpSchurImpl::S
private

◆ schurDM

SmartPetscObj< DM > SetUpSchurImpl::schurDM
private

◆ subDM

SmartPetscObj< DM > SetUpSchurImpl::subDM
private

field split sub dm

Examples
mofem/tutorials/adv-0_plasticity/plastic.cpp, plastic.cpp, and thermoplastic.cpp.

Definition at line 1686 of file plastic.cpp.

◆ subEnts

Range SetUpSchurImpl::subEnts
private

◆ volEnts

Range SetUpSchurImpl::volEnts
private

The documentation for this struct was generated from the following files: