 |
| v0.14.0
|
Set of functions called by PETSc solver used to refine and update mesh.
More...
|
static MoFEMErrorCode | tsPreProc (TS ts) |
| Pre process time step. More...
|
|
static MoFEMErrorCode | tsPostProc (TS ts) |
| Post process time step. More...
|
|
static MoFEMErrorCode | tsPreStage (TS ts) |
|
static MoFEMErrorCode | tsSetIFunction (TS ts, PetscReal t, Vec u, Vec u_t, Vec f, void *ctx) |
|
static MoFEMErrorCode | tsSetIJacobian (TS ts, PetscReal t, Vec u, Vec u_t, PetscReal a, Mat A, Mat B, void *ctx) |
| Wrapper for SNES Lhs. More...
|
|
static MoFEMErrorCode | tsMonitor (TS ts, PetscInt step, PetscReal t, Vec u, void *ctx) |
| Wrapper for TS monitor. More...
|
|
static MoFEMErrorCode | pcSetup (PC pc) |
|
static MoFEMErrorCode | pcApply (PC pc, Vec pc_f, Vec pc_x) |
|
Set of functions called by PETSc solver used to refine and update mesh.
- Note
- Currently theta method is only handled by this code.
- Examples
- dynamic_first_order_con_law.cpp, and free_surface.cpp.
Definition at line 383 of file dynamic_first_order_con_law.cpp.
◆ TSPrePostProc() [1/2]
TSPrePostProc::TSPrePostProc |
( |
| ) |
|
|
default |
◆ ~TSPrePostProc() [1/2]
virtual TSPrePostProc::~TSPrePostProc |
( |
| ) |
|
|
virtualdefault |
◆ TSPrePostProc() [2/2]
TSPrePostProc::TSPrePostProc |
( |
| ) |
|
|
default |
◆ ~TSPrePostProc() [2/2]
virtual TSPrePostProc::~TSPrePostProc |
( |
| ) |
|
|
virtualdefault |
◆ getScatter()
SmartPetscObj< VecScatter > TSPrePostProc::getScatter |
( |
Vec |
x, |
|
|
Vec |
y, |
|
|
enum FR |
fr |
|
) |
| |
- Examples
- free_surface.cpp.
Definition at line 3107 of file free_surface.cpp.
3109 auto prb_ptr = ptr->fsRawPtr->mField.get_problem(
"SUB_SOLVER");
3110 if (
auto sub_data = prb_ptr->getSubData()) {
3111 auto is = sub_data->getSmartColIs();
◆ getSubVector()
◆ pcApply()
- Examples
- free_surface.cpp.
Definition at line 3087 of file free_surface.cpp.
3090 auto sub_x = ptr->getSubVector();
3092 auto scatter = ptr->getScatter(sub_x, pc_x,
R);
3093 CHKERR VecScatterBegin(scatter, pc_f, sub_f, INSERT_VALUES,
3095 CHKERR VecScatterEnd(scatter, pc_f, sub_f, INSERT_VALUES, SCATTER_REVERSE);
3096 CHKERR KSPSetOperators(ptr->subKSP, ptr->subB, ptr->subB);
3097 MOFEM_LOG(
"FS", Sev::verbose) <<
"PCShell solve";
3098 CHKERR KSPSolve(ptr->subKSP, sub_f, sub_x);
3099 MOFEM_LOG(
"FS", Sev::verbose) <<
"PCShell solve <- done";
3100 CHKERR VecScatterBegin(scatter, sub_x, pc_x, INSERT_VALUES,
3102 CHKERR VecScatterEnd(scatter, sub_x, pc_x, INSERT_VALUES, SCATTER_FORWARD);
◆ pcSetup()
◆ tsMonitor()
MoFEMErrorCode TSPrePostProc::tsMonitor |
( |
TS |
ts, |
|
|
PetscInt |
step, |
|
|
PetscReal |
t, |
|
|
Vec |
u, |
|
|
void * |
ctx |
|
) |
| |
|
staticprivate |
Wrapper for TS monitor.
- Examples
- free_surface.cpp.
Definition at line 3052 of file free_surface.cpp.
3056 auto get_norm = [&](
auto x) {
3058 CHKERR VecNorm(x, NORM_2, &nrm);
3062 auto sub_u = ptr->getSubVector();
3063 auto scatter = ptr->getScatter(sub_u, u,
R);
3064 CHKERR VecScatterBegin(scatter, u, sub_u, INSERT_VALUES, SCATTER_REVERSE);
3065 CHKERR VecScatterEnd(scatter, u, sub_u, INSERT_VALUES, SCATTER_REVERSE);
3066 CHKERR VecGhostUpdateBegin(sub_u, INSERT_VALUES, SCATTER_FORWARD);
3067 CHKERR VecGhostUpdateEnd(sub_u, INSERT_VALUES, SCATTER_FORWARD);
3070 <<
"u norm " << get_norm(u) <<
" u sub nom " << get_norm(sub_u);
◆ tsPostProc()
Post process time step.
Currently that function do not make anything major
- Parameters
-
- Returns
- MoFEMErrorCode
- Examples
- free_surface.cpp.
Definition at line 2987 of file free_surface.cpp.
2989 auto &m_field = ptr->fsRawPtr->mField;
◆ tsPostStage()
MoFEMErrorCode TSPrePostProc::tsPostStage |
( |
TS |
ts, |
|
|
PetscReal |
stagetime, |
|
|
PetscInt |
stageindex, |
|
|
Vec * |
Y |
|
) |
| |
|
static |
[Boundary condition]
- Examples
- dynamic_first_order_con_law.cpp.
Definition at line 580 of file dynamic_first_order_con_law.cpp.
585 auto &m_field = ptr->fsRawPtr->mField;
587 auto fb = m_field.getInterface<
FieldBlas>();
591 CHKERR TSGetTime(ts, &time);
593 Vec *stage_solutions;
595 CHKERR TSGetStages(ts, &num_stages, &stage_solutions);
596 PetscPrintf(PETSC_COMM_WORLD,
"Check timestep %d time %e dt %e\n",
597 num_stages, time,
dt);
599 const double inv_num_step = (
double)num_stages;
600 CHKERR fb->fieldCopy(1.,
"x_1",
"x_2");
601 CHKERR fb->fieldAxpy(
dt,
"V",
"x_2");
602 CHKERR fb->fieldCopy(1.,
"x_2",
"x_1");
604 CHKERR fb->fieldCopy(-inv_num_step /
dt,
"F_0",
"F_dot");
605 CHKERR fb->fieldAxpy(inv_num_step /
dt,
"F",
"F_dot");
606 CHKERR fb->fieldCopy(1.,
"F",
"F_0");
◆ tsPostStep()
◆ tsPreProc()
Pre process time step.
Refine mesh and update fields
- Parameters
-
- Returns
- MoFEMErrorCode
cut-off values at nodes, i.e. abs("H") <= 1
- Examples
- free_surface.cpp.
Definition at line 2872 of file free_surface.cpp.
2881 auto cut_off_dofs = [&]() {
2884 auto &m_field = ptr->fsRawPtr->mField;
2886 Range current_verts;
2888 CHKERR bit_mng->getEntitiesByTypeAndRefLevel(
2891 auto cut_off_verts = [&](boost::shared_ptr<FieldEntity> ent_ptr) {
2893 for (
auto &
h : ent_ptr->getEntFieldData()) {
2899 auto field_blas = m_field.getInterface<
FieldBlas>();
2900 CHKERR field_blas->fieldLambdaOnEntities(cut_off_verts,
"H",
2909 MOFEM_LOG(
"FS", Sev::inform) <<
"Run step pre proc";
2911 auto &m_field = ptr->fsRawPtr->mField;
2915 auto get_norm = [&](
auto x) {
2917 CHKERR VecNorm(x, NORM_2, &nrm);
2922 auto refine_problem = [&]() {
2924 MOFEM_LOG(
"FS", Sev::inform) <<
"Refine problem";
2926 CHKERR ptr->fsRawPtr->projectData();
2932 auto set_jacobian_operators = [&]() {
2935 CHKERR KSPReset(ptr->subKSP);
2940 auto set_solution = [&]() {
2942 MOFEM_LOG(
"FS", Sev::inform) <<
"Set solution";
2944 PetscObjectState state;
2955 INSERT_VALUES, SCATTER_FORWARD);
2958 <<
"Set solution, vector norm " << get_norm(ptr->globSol);
2963 PetscObjectTypeCompare((PetscObject)ts, TSTHETA, &is_theta);
2967 CHKERR set_jacobian_operators();
2972 "Sorry, only TSTheta handling is implemented");
2977 PetscBarrier((PetscObject)ts);
◆ tsPreStage()
◆ tsPreStep()
◆ tsSetIFunction()
MoFEMErrorCode TSPrePostProc::tsSetIFunction |
( |
TS |
ts, |
|
|
PetscReal |
t, |
|
|
Vec |
u, |
|
|
Vec |
u_t, |
|
|
Vec |
f, |
|
|
void * |
ctx |
|
) |
| |
|
staticprivate |
- Examples
- free_surface.cpp.
Definition at line 2997 of file free_surface.cpp.
3001 auto sub_u = ptr->getSubVector();
3004 auto scatter = ptr->getScatter(sub_u, u,
R);
3006 auto apply_scatter_and_update = [&](
auto x,
auto sub_x) {
3008 CHKERR VecScatterBegin(scatter, x, sub_x, INSERT_VALUES, SCATTER_REVERSE);
3009 CHKERR VecScatterEnd(scatter, x, sub_x, INSERT_VALUES, SCATTER_REVERSE);
3010 CHKERR VecGhostUpdateBegin(sub_x, INSERT_VALUES, SCATTER_FORWARD);
3011 CHKERR VecGhostUpdateEnd(sub_x, INSERT_VALUES, SCATTER_FORWARD);
3015 CHKERR apply_scatter_and_update(u, sub_u);
3016 CHKERR apply_scatter_and_update(u_t, sub_u_t);
3019 CHKERR VecScatterBegin(scatter, sub_f,
f, INSERT_VALUES, SCATTER_FORWARD);
3020 CHKERR VecScatterEnd(scatter, sub_f,
f, INSERT_VALUES, SCATTER_FORWARD);
◆ tsSetIJacobian()
MoFEMErrorCode TSPrePostProc::tsSetIJacobian |
( |
TS |
ts, |
|
|
PetscReal |
t, |
|
|
Vec |
u, |
|
|
Vec |
u_t, |
|
|
PetscReal |
a, |
|
|
Mat |
A, |
|
|
Mat |
B, |
|
|
void * |
ctx |
|
) |
| |
|
staticprivate |
Wrapper for SNES Lhs.
- Examples
- free_surface.cpp.
Definition at line 3025 of file free_surface.cpp.
3030 auto sub_u = ptr->getSubVector();
3032 auto scatter = ptr->getScatter(sub_u, u,
R);
3034 auto apply_scatter_and_update = [&](
auto x,
auto sub_x) {
3036 CHKERR VecScatterBegin(scatter, x, sub_x, INSERT_VALUES, SCATTER_REVERSE);
3037 CHKERR VecScatterEnd(scatter, x, sub_x, INSERT_VALUES, SCATTER_REVERSE);
3038 CHKERR VecGhostUpdateBegin(sub_x, INSERT_VALUES, SCATTER_FORWARD);
3039 CHKERR VecGhostUpdateEnd(sub_x, INSERT_VALUES, SCATTER_FORWARD);
3043 CHKERR apply_scatter_and_update(u, sub_u);
3044 CHKERR apply_scatter_and_update(u_t, sub_u_t);
3047 ptr->tsCtxPtr.get());
◆ tsSetUp() [1/2]
Used to setup TS solver.
- Parameters
-
- Returns
- MoFEMErrorCode
- Examples
- free_surface.cpp.
Definition at line 3131 of file free_surface.cpp.
3138 auto dm =
simple->getDM();
3146 CHKERR TSGetSNES(ts, &snes);
3149 auto set_section_monitor = [&](
auto snes) {
3151 CHKERR SNESMonitorSet(snes,
3154 (
void *)(snes_ctx_ptr.get()),
nullptr);
3158 CHKERR set_section_monitor(snes);
3160 auto ksp =
createKSP(m_field.get_comm());
3161 CHKERR KSPSetType(ksp, KSPPREONLY);
3163 CHKERR PCSetType(sub_pc, PCSHELL);
3166 CHKERR KSPSetPC(ksp, sub_pc);
3167 CHKERR SNESSetKSP(snes, ksp);
◆ tsSetUp() [2/2]
Used to setup TS solver.
- Parameters
-
- Returns
- MoFEMErrorCode
◆ fsRawPtr [1/2]
◆ fsRawPtr [2/2]
◆ globRes
◆ globSol
◆ snesCtxPtr
boost::shared_ptr<SnesCtx> TSPrePostProc::snesCtxPtr |
|
private |
◆ solverSubDM
◆ subB
◆ subKSP
◆ tsCtxPtr
boost::shared_ptr<TsCtx> TSPrePostProc::tsCtxPtr |
|
private |
The documentation for this struct was generated from the following files:
SmartPetscObj< DM > solverSubDM
#define MOFEM_LOG_SEVERITY_SYNC(comm, severity)
Synchronise "SYNC" on curtain severity level.
#define MOFEM_LOG_CHANNEL(channel)
Set and reset channel.
virtual MPI_Comm & get_comm() const =0
PetscErrorCode TsSetIFunction(TS ts, PetscReal t, Vec u, Vec u_t, Vec F, void *ctx)
Set IFunction for TS solver.
#define CHK_THROW_MESSAGE(err, msg)
Check and throw MoFEM exception.
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
PetscObject getPetscObject(T obj)
PetscErrorCode DMoFEMMeshToLocalVector(DM dm, Vec l, InsertMode mode, ScatterMode scatter_mode)
set local (or ghosted) vector values on mesh for partition only
auto createKSP(MPI_Comm comm)
static boost::weak_ptr< TSPrePostProc > tsPrePostProc
Simple interface for fast problem set-up.
auto createDMMatrix(DM dm)
Get smart matrix from DM.
PetscErrorCode TsMonitorSet(TS ts, PetscInt step, PetscReal t, Vec u, void *ctx)
Set monitor for TS solver.
#define CHKERR
Inline error check.
auto createDMVector(DM dm)
Get smart vector from DM.
static MoFEMErrorCode tsMonitor(TS ts, PetscInt step, PetscReal t, Vec u, void *ctx)
Wrapper for TS monitor.
auto get_current_bit
dofs bit used to do calculations
void simple(double P1[], double P2[], double P3[], double c[], const int N)
static MoFEMErrorCode tsSetIFunction(TS ts, PetscReal t, Vec u, Vec u_t, Vec f, void *ctx)
static MoFEMErrorCode tsPostProc(TS ts)
Post process time step.
auto createPC(MPI_Comm comm)
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.
constexpr double t
plate stiffness
boost::shared_ptr< SnesCtx > snesCtxPtr
static boost::weak_ptr< TSPrePostProc > tsPrePostProc
static MoFEMErrorCode tsPreProc(TS ts)
Pre process time step.
#define MOFEM_TAG_AND_LOG(channel, severity, tag)
Tag and log in channel.
#define MOFEM_LOG(channel, severity)
Log.
boost::shared_ptr< TsCtx > tsCtxPtr
SmartPetscObj< Vec > vectorDuplicate(Vec vec)
Create duplicate vector of smart vector.
static MoFEMErrorCode tsSetIJacobian(TS ts, PetscReal t, Vec u, Vec u_t, PetscReal a, Mat A, Mat B, void *ctx)
Wrapper for SNES Lhs.
const FTensor::Tensor2< T, Dim, Dim > Vec
@ MOFEM_DATA_INCONSISTENCY
MoFEMErrorCode MoFEMSNESMonitorFields(SNES snes, PetscInt its, PetscReal fgnorm, SnesCtx *snes_ctx)
Sens monitor printing residual field by field.
SmartPetscObj< Vec > globSol
MoFEM::Interface & mField
static MoFEMErrorCode pcSetup(PC pc)
std::bitset< BITREFLEVEL_SIZE > BitRefLevel
Bit structure attached to each entity identifying to what mesh entity is attached.
auto getDMSnesCtx(DM dm)
Get SNES context data structure used by DM.
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
SmartPetscObj< Vec > globRes
auto getDMTsCtx(DM dm)
Get TS context data structure used by DM.
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
static MoFEMErrorCode pcApply(PC pc, Vec pc_f, Vec pc_x)