v0.13.2
Loading...
Searching...
No Matches
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]

Public Member Functions

 SetUpSchurImpl (MoFEM::Interface &m_field, SmartPetscObj< DM > sub_dm, SmartPetscObj< IS > field_split_is, SmartPetscObj< AO > ao_up)
 
virtual ~SetUpSchurImpl ()
 
MoFEMErrorCode setUp (KSP solver)
 
MoFEMErrorCode preProc ()
 
MoFEMErrorCode postProc ()
 
 SetUpSchurImpl (MoFEM::Interface &m_field)
 
virtual ~SetUpSchurImpl ()
 
MoFEMErrorCode setUp (SmartPetscObj< KSP > solver)
 
MoFEMErrorCode preProc ()
 
MoFEMErrorCode postProc ()
 
virtual MoFEMErrorCode setUp (KSP solver)=0
 
virtual MoFEMErrorCode preProc ()=0
 
virtual MoFEMErrorCode postProc ()=0
 
virtual MoFEMErrorCode setUp (SmartPetscObj< KSP > solver)=0
 
virtual MoFEMErrorCode preProc ()=0
 
virtual MoFEMErrorCode postProc ()=0
 

Private Member Functions

MoFEMErrorCode setEntities ()
 
MoFEMErrorCode setUpSubDM ()
 
MoFEMErrorCode setOperator ()
 
MoFEMErrorCode setPC (PC pc)
 

Private Attributes

SmartPetscObj< Mat > S
 
MoFEM::InterfacemField
 
SmartPetscObj< DM > subDM
 field split sub dm More...
 
SmartPetscObj< IS > fieldSplitIS
 IS for split Schur block. More...
 
SmartPetscObj< AO > aoUp
 
Range volEnts
 
Range subEnts
 

Additional Inherited Members

- Static Public Member Functions inherited from SetUpSchur
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. More...
 
static boost::shared_ptr< SetUpSchurcreateSetUpSchur (MoFEM::Interface &m_field)
 
- Protected Member Functions inherited from SetUpSchur
 SetUpSchur ()=default
 
 SetUpSchur ()=default
 

Detailed Description

Examples
EshelbianPlasticity.cpp, and plastic.cpp.

Definition at line 1231 of file plastic.cpp.

Constructor & Destructor Documentation

◆ SetUpSchurImpl() [1/2]

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

Definition at line 1233 of file plastic.cpp.

1235 : SetUpSchur(), mField(m_field), subDM(sub_dm),
1236 fieldSplitIS(field_split_is), aoUp(ao_up) {
1237 if (S) {
1240 "Is expected that schur matrix is not allocated. This is "
1241 "possible only is PC is set up twice");
1242 }
1243 }
#define CHK_THROW_MESSAGE(err, msg)
Check and throw MoFEM exception.
Definition: definitions.h:595
@ MOFEM_DATA_INCONSISTENCY
Definition: definitions.h:31
SetUpSchur()=default
SmartPetscObj< DM > subDM
field split sub dm
Definition: plastic.cpp:1254
SmartPetscObj< Mat > S
Definition: plastic.cpp:1251
SmartPetscObj< IS > fieldSplitIS
IS for split Schur block.
Definition: plastic.cpp:1255
SmartPetscObj< AO > aoUp
Definition: plastic.cpp:1256
MoFEM::Interface & mField
Definition: plastic.cpp:1253

◆ ~SetUpSchurImpl() [1/2]

virtual SetUpSchurImpl::~SetUpSchurImpl ( )
inlinevirtual
Examples
plastic.cpp.

Definition at line 1244 of file plastic.cpp.

1244{ S.reset(); }

◆ SetUpSchurImpl() [2/2]

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

Definition at line 733 of file elastic.cpp.

733 : SetUpSchur(), mField(m_field) {
734 if (S) {
737 "Is expected that schur matrix is not allocated. This is "
738 "possible only is PC is set up twice");
739 }
740 }

◆ ~SetUpSchurImpl() [2/2]

virtual SetUpSchurImpl::~SetUpSchurImpl ( )
inlinevirtual

Definition at line 741 of file elastic.cpp.

741{ S.reset(); }

Member Function Documentation

◆ postProc() [1/2]

MoFEMErrorCode SetUpSchurImpl::postProc ( )
virtual

Implements SetUpSchur.

Examples
plastic.cpp.

Definition at line 1335 of file plastic.cpp.

1335 {
1337 MOFEM_LOG("TIMER", Sev::verbose) << "Lhs Assemble End";
1338 if (S) {
1339 CHKERR MatAssemblyBegin(S, MAT_FINAL_ASSEMBLY);
1340 CHKERR MatAssemblyEnd(S, MAT_FINAL_ASSEMBLY);
1341 }
1343}
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:346
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:416
#define CHKERR
Inline error check.
Definition: definitions.h:535
#define MOFEM_LOG(channel, severity)
Log.
Definition: LogManager.hpp:308

◆ postProc() [2/2]

MoFEMErrorCode SetUpSchurImpl::postProc ( )
virtual

Implements SetUpSchur.

◆ preProc() [1/2]

MoFEMErrorCode SetUpSchurImpl::preProc ( )
virtual

Implements SetUpSchur.

Examples
plastic.cpp.

Definition at line 1326 of file plastic.cpp.

1326 {
1328 if (SetUpSchurImpl::S) {
1329 CHKERR MatZeroEntries(S);
1330 }
1331 MOFEM_LOG("TIMER", Sev::verbose) << "Lhs Assemble Begin";
1333}

◆ preProc() [2/2]

MoFEMErrorCode SetUpSchurImpl::preProc ( )
virtual

Implements SetUpSchur.

◆ setEntities()

MoFEMErrorCode SetUpSchurImpl::setEntities ( )
private

Definition at line 795 of file elastic.cpp.

795 {
798 CHKERR mField.get_moab().get_entities_by_dimension(simple->getMeshset(),
800 CHKERR mField.get_moab().get_entities_by_handle(simple->getMeshset(),
801 subEnts);
802 subEnts = subtract(subEnts, volEnts);
804};
void simple(double P1[], double P2[], double P3[], double c[], const int N)
Definition: acoustic.cpp:69
constexpr int SPACE_DIM
[Define dimension]
Definition: elastic.cpp:16
virtual moab::Interface & get_moab()=0
Simple interface for fast problem set-up.
Definition: Simple.hpp:27
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface refernce to pointer of interface.

◆ setOperator()

MoFEMErrorCode SetUpSchurImpl::setOperator ( )
private

Definition at line 820 of file elastic.cpp.

820 {
822 auto pip = mField.getInterface<PipelineManager>();
823 // Boundary
824 auto dm_is = getDMSubData(subDM)->getSmartRowIs();
825 auto ao_up = createAOMappingIS(dm_is, PETSC_NULL);
826 pip->getOpBoundaryLhsPipeline().push_front(new OpSchurAssembleBegin());
827 pip->getOpBoundaryLhsPipeline().push_back(new OpSchurAssembleEnd<SCHUR_DSYSV>(
828 {"U"}, {boost::make_shared<Range>(volEnts)}, {ao_up}, {S}, {true}));
829 // Domain
830 pip->getOpDomainLhsPipeline().push_front(new OpSchurAssembleBegin());
831 pip->getOpDomainLhsPipeline().push_back(new OpSchurAssembleEnd<SCHUR_DSYSV>(
832 {"U"}, {boost::make_shared<Range>(volEnts)}, {ao_up}, {S}, {true}));
834}
auto getDMSubData(DM dm)
Get sub problem data structure.
Definition: DMMoFEM.hpp:1061
auto createAOMappingIS(IS isapp, IS ispetsc)
Creates an application mapping using two index sets.
Clear Schur complement internal data.
Definition: Schur.hpp:22
Assemble Schur complement.
Definition: Schur.hpp:105
PipelineManager interface.

◆ setPC()

MoFEMErrorCode SetUpSchurImpl::setPC ( PC  pc)
private

Definition at line 836 of file elastic.cpp.

836 {
839 SmartPetscObj<IS> vol_is;
840 mField.getInterface<ISManager>()->isCreateProblemFieldAndRank(
841 simple->getProblemName(), ROW, "U", 0, SPACE_DIM, vol_is, &volEnts);
842 CHKERR PCFieldSplitSetIS(pc, NULL, vol_is);
843 CHKERR PCFieldSplitSetSchurPre(pc, PC_FIELDSPLIT_SCHUR_PRE_USER, S);
845}
@ ROW
Definition: definitions.h:123
Section manager is used to create indexes and sections.
Definition: ISManager.hpp:23
intrusive_ptr for managing petsc objects

◆ setUp() [1/2]

MoFEMErrorCode SetUpSchurImpl::setUp ( KSP  solver)
virtual

Implements SetUpSchur.

Examples
plastic.cpp.

Definition at line 1259 of file plastic.cpp.

1259 {
1261 auto pip = mField.getInterface<PipelineManager>();
1262 PC pc;
1263 CHKERR KSPSetFromOptions(solver);
1264 CHKERR KSPGetPC(solver, &pc);
1265 PetscBool is_pcfs = PETSC_FALSE;
1266 PetscObjectTypeCompare((PetscObject)pc, PCFIELDSPLIT, &is_pcfs);
1267 if (is_pcfs) {
1268 if (S) {
1271 "Is expected that schur matrix is not allocated. This is "
1272 "possible only is PC is set up twice");
1273 }
1275
1276 auto set_ops = [&]() {
1278 auto pip = mField.getInterface<PipelineManager>();
1279 // Boundary
1280 pip->getOpBoundaryLhsPipeline().push_front(new OpSchurAssembleBegin());
1281 pip->getOpBoundaryLhsPipeline().push_back(
1283
1284 {"EP", "TAU"}, {nullptr, nullptr}, {SmartPetscObj<AO>(), aoUp},
1285 {SmartPetscObj<Mat>(), S}, {false, false}
1286
1287 ));
1288 // Domain
1289 pip->getOpDomainLhsPipeline().push_front(new OpSchurAssembleBegin());
1290 pip->getOpDomainLhsPipeline().push_back(
1292
1293 {"EP", "TAU"}, {nullptr, nullptr}, {SmartPetscObj<AO>(), aoUp},
1294 {SmartPetscObj<Mat>(), S}, {false, false}
1295
1296 ));
1298 };
1299
1300 auto set_pc = [&]() {
1302 CHKERR PCFieldSplitSetIS(pc, NULL, fieldSplitIS);
1303 CHKERR PCFieldSplitSetSchurPre(pc, PC_FIELDSPLIT_SCHUR_PRE_USER, S);
1305 };
1306
1307 CHKERR set_ops();
1308 CHKERR set_pc();
1309
1310 } else {
1311 pip->getOpBoundaryLhsPipeline().push_front(new OpSchurAssembleBegin());
1312 pip->getOpBoundaryLhsPipeline().push_back(
1313 new OpSchurAssembleEnd<SCHUR_DGESV>({}, {}, {}, {}, {}));
1314 pip->getOpDomainLhsPipeline().push_front(new OpSchurAssembleBegin());
1315 pip->getOpDomainLhsPipeline().push_back(
1316 new OpSchurAssembleEnd<SCHUR_DGESV>({}, {}, {}, {}, {}));
1317 }
1318
1319 // we do not those anymore
1320 subDM.reset();
1321 fieldSplitIS.reset();
1322 aoUp.reset();
1324}
auto createDMMatrix(DM dm)
Get smart matrix from DM.
Definition: DMMoFEM.hpp:988
boost::ptr_deque< UserDataOperator > & getOpBoundaryLhsPipeline()
Get the Op Boundary Lhs Pipeline object.

◆ setUp() [2/2]

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

Implements SetUpSchur.

Definition at line 763 of file elastic.cpp.

763 {
765 auto pip = mField.getInterface<PipelineManager>();
766 PC pc;
767 CHKERR KSPGetPC(solver, &pc);
768 PetscBool is_pcfs = PETSC_FALSE;
769 PetscObjectTypeCompare((PetscObject)pc, PCFIELDSPLIT, &is_pcfs);
770 if (is_pcfs) {
771 if (S) {
774 "Is expected that schur matrix is not allocated. This is "
775 "possible only is PC is set up twice");
776 }
780 // CHKERR MatSetBlockSize(S, SPACE_DIM);
781 // CHKERR MatSetOption(S, MAT_SYMMETRIC, PETSC_TRUE);
783 CHKERR setPC(pc);
784 } else {
785 pip->getOpBoundaryLhsPipeline().push_front(new OpSchurAssembleBegin());
786 pip->getOpBoundaryLhsPipeline().push_back(
787 new OpSchurAssembleEnd<SCHUR_DSYSV>({}, {}, {}, {}, {}));
788 pip->getOpDomainLhsPipeline().push_front(new OpSchurAssembleBegin());
789 pip->getOpDomainLhsPipeline().push_back(
790 new OpSchurAssembleEnd<SCHUR_DSYSV>({}, {}, {}, {}, {}));
791 }
793}
MoFEMErrorCode setEntities()
Definition: elastic.cpp:795
MoFEMErrorCode setPC(PC pc)
Definition: elastic.cpp:836
MoFEMErrorCode setUpSubDM()
Definition: elastic.cpp:806
MoFEMErrorCode setOperator()
Definition: elastic.cpp:820

◆ setUpSubDM()

MoFEMErrorCode SetUpSchurImpl::setUpSubDM ( )
private

Definition at line 806 of file elastic.cpp.

806 {
809 subDM = createDM(mField.get_comm(), "DMMOFEM");
810 CHKERR DMMoFEMCreateSubDM(subDM, simple->getDM(), "SUB");
812 CHKERR DMMoFEMAddElement(subDM, simple->getDomainFEName());
813 auto sub_ents_ptr = boost::make_shared<Range>(subEnts);
814 CHKERR DMMoFEMAddSubFieldRow(subDM, "U", sub_ents_ptr);
815 CHKERR DMMoFEMAddSubFieldCol(subDM, "U", sub_ents_ptr);
816 CHKERR DMSetUp(subDM);
818}
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:219
PetscErrorCode DMMoFEMAddElement(DM dm, std::string fe_name)
add element to dm
Definition: DMMoFEM.cpp:483
PetscErrorCode DMMoFEMSetSquareProblem(DM dm, PetscBool square_problem)
set squared problem
Definition: DMMoFEM.cpp:442
PetscErrorCode DMMoFEMAddSubFieldRow(DM dm, const char field_name[])
Definition: DMMoFEM.cpp:242
PetscErrorCode DMMoFEMAddSubFieldCol(DM dm, const char field_name[])
Definition: DMMoFEM.cpp:275
auto createDM(MPI_Comm comm, const std::string dm_type_name)
Creates smart DM object.
virtual MPI_Comm & get_comm() const =0

Member Data Documentation

◆ aoUp

SmartPetscObj<AO> SetUpSchurImpl::aoUp
private
Examples
plastic.cpp.

Definition at line 1256 of file plastic.cpp.

◆ fieldSplitIS

SmartPetscObj<IS> SetUpSchurImpl::fieldSplitIS
private

IS for split Schur block.

Examples
plastic.cpp.

Definition at line 1255 of file plastic.cpp.

◆ mField

MoFEM::Interface & SetUpSchurImpl::mField
private
Examples
plastic.cpp.

Definition at line 1253 of file plastic.cpp.

◆ S

SmartPetscObj< Mat > SetUpSchurImpl::S
private
Examples
plastic.cpp.

Definition at line 1251 of file plastic.cpp.

◆ subDM

SmartPetscObj< DM > SetUpSchurImpl::subDM
private

field split sub dm

Examples
plastic.cpp.

Definition at line 1254 of file plastic.cpp.

◆ subEnts

Range SetUpSchurImpl::subEnts
private

Definition at line 759 of file elastic.cpp.

◆ volEnts

Range SetUpSchurImpl::volEnts
private

Definition at line 758 of file elastic.cpp.


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