|
| 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 384 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 3118 of file free_surface.cpp.
3120 auto prb_ptr = ptr->fsRawPtr->mField.get_problem(
"SUB_SOLVER");
3121 if (
auto sub_data = prb_ptr->getSubData()) {
3122 auto is = sub_data->getSmartColIs();
◆ getSubVector()
◆ pcApply()
- Examples
- free_surface.cpp.
Definition at line 3098 of file free_surface.cpp.
3101 auto sub_x = ptr->getSubVector();
3103 auto scatter = ptr->getScatter(sub_x, pc_x,
R);
3104 CHKERR VecScatterBegin(scatter, pc_f, sub_f, INSERT_VALUES,
3106 CHKERR VecScatterEnd(scatter, pc_f, sub_f, INSERT_VALUES, SCATTER_REVERSE);
3107 CHKERR KSPSetOperators(ptr->subKSP, ptr->subB, ptr->subB);
3108 MOFEM_LOG(
"FS", Sev::verbose) <<
"PCShell solve";
3109 CHKERR KSPSolve(ptr->subKSP, sub_f, sub_x);
3110 MOFEM_LOG(
"FS", Sev::verbose) <<
"PCShell solve <- done";
3111 CHKERR VecScatterBegin(scatter, sub_x, pc_x, INSERT_VALUES,
3113 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 3063 of file free_surface.cpp.
3067 auto get_norm = [&](
auto x) {
3069 CHKERR VecNorm(x, NORM_2, &nrm);
3073 auto sub_u = ptr->getSubVector();
3074 auto scatter = ptr->getScatter(sub_u, u,
R);
3075 CHKERR VecScatterBegin(scatter, u, sub_u, INSERT_VALUES, SCATTER_REVERSE);
3076 CHKERR VecScatterEnd(scatter, u, sub_u, INSERT_VALUES, SCATTER_REVERSE);
3077 CHKERR VecGhostUpdateBegin(sub_u, INSERT_VALUES, SCATTER_FORWARD);
3078 CHKERR VecGhostUpdateEnd(sub_u, INSERT_VALUES, SCATTER_FORWARD);
3081 <<
"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 2998 of file free_surface.cpp.
3000 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 581 of file dynamic_first_order_con_law.cpp.
586 auto &m_field = ptr->fsRawPtr->mField;
594 CHKERR TSGetTime(ts, &time);
596 Vec *stage_solutions;
598 CHKERR TSGetStages(ts, &num_stages, &stage_solutions);
599 PetscPrintf(PETSC_COMM_WORLD,
"Check timestep %d time %e dt %e\n",
600 num_stages, time,
dt);
602 const double inv_num_step = (
double)num_stages;
603 CHKERR fb->fieldCopy(1.,
"x_1",
"x_2");
604 CHKERR fb->fieldAxpy(
dt,
"V",
"x_2");
605 CHKERR fb->fieldCopy(1.,
"x_2",
"x_1");
607 CHKERR fb->fieldCopy(-inv_num_step /
dt,
"F_0",
"F_dot");
608 CHKERR fb->fieldAxpy(inv_num_step /
dt,
"F",
"F_dot");
609 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 2877 of file free_surface.cpp.
2886 auto cut_off_dofs = [&]() {
2889 auto &m_field = ptr->fsRawPtr->mField;
2891 Range current_verts;
2893 CHKERR bit_mng->getEntitiesByTypeAndRefLevel(
2896 auto cut_off_verts = [&](boost::shared_ptr<FieldEntity> ent_ptr) {
2898 for (
auto &
h : ent_ptr->getEntFieldData()) {
2904 auto field_blas = m_field.getInterface<
FieldBlas>();
2905 CHKERR field_blas->fieldLambdaOnEntities(cut_off_verts,
"H",
2914 MOFEM_LOG(
"FS", Sev::inform) <<
"Run step pre proc";
2916 auto &m_field = ptr->fsRawPtr->mField;
2926 auto get_norm = [&](
auto x) {
2928 CHKERR VecNorm(x, NORM_2, &nrm);
2933 auto refine_problem = [&]() {
2935 MOFEM_LOG(
"FS", Sev::inform) <<
"Refine problem";
2937 CHKERR ptr->fsRawPtr->projectData();
2943 auto set_jacobian_operators = [&]() {
2946 CHKERR KSPReset(ptr->subKSP);
2951 auto set_solution = [&]() {
2953 MOFEM_LOG(
"FS", Sev::inform) <<
"Set solution";
2955 PetscObjectState state;
2966 INSERT_VALUES, SCATTER_FORWARD);
2969 <<
"Set solution, vector norm " << get_norm(ptr->globSol);
2974 PetscObjectTypeCompare((PetscObject)ts, TSTHETA, &is_theta);
2978 CHKERR set_jacobian_operators();
2983 "Sorry, only TSTheta handling is implemented");
2988 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 3008 of file free_surface.cpp.
3012 auto sub_u = ptr->getSubVector();
3015 auto scatter = ptr->getScatter(sub_u, u,
R);
3017 auto apply_scatter_and_update = [&](
auto x,
auto sub_x) {
3019 CHKERR VecScatterBegin(scatter, x, sub_x, INSERT_VALUES, SCATTER_REVERSE);
3020 CHKERR VecScatterEnd(scatter, x, sub_x, INSERT_VALUES, SCATTER_REVERSE);
3021 CHKERR VecGhostUpdateBegin(sub_x, INSERT_VALUES, SCATTER_FORWARD);
3022 CHKERR VecGhostUpdateEnd(sub_x, INSERT_VALUES, SCATTER_FORWARD);
3026 CHKERR apply_scatter_and_update(u, sub_u);
3027 CHKERR apply_scatter_and_update(u_t, sub_u_t);
3030 CHKERR VecScatterBegin(scatter, sub_f,
f, INSERT_VALUES, SCATTER_FORWARD);
3031 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 3036 of file free_surface.cpp.
3041 auto sub_u = ptr->getSubVector();
3043 auto scatter = ptr->getScatter(sub_u, u,
R);
3045 auto apply_scatter_and_update = [&](
auto x,
auto sub_x) {
3047 CHKERR VecScatterBegin(scatter, x, sub_x, INSERT_VALUES, SCATTER_REVERSE);
3048 CHKERR VecScatterEnd(scatter, x, sub_x, INSERT_VALUES, SCATTER_REVERSE);
3049 CHKERR VecGhostUpdateBegin(sub_x, INSERT_VALUES, SCATTER_FORWARD);
3050 CHKERR VecGhostUpdateEnd(sub_x, INSERT_VALUES, SCATTER_FORWARD);
3054 CHKERR apply_scatter_and_update(u, sub_u);
3055 CHKERR apply_scatter_and_update(u_t, sub_u_t);
3058 ptr->tsCtxPtr.get());
◆ tsSetUp() [1/2]
Used to setup TS solver.
- Parameters
-
- Returns
- MoFEMErrorCode
- Examples
- free_surface.cpp.
Definition at line 3142 of file free_surface.cpp.
3149 auto dm =
simple->getDM();
3157 CHKERR TSGetSNES(ts, &snes);
3160 auto set_section_monitor = [&](
auto snes) {
3162 CHKERR SNESMonitorSet(snes,
3165 (
void *)(snes_ctx_ptr.get()),
nullptr);
3169 CHKERR set_section_monitor(snes);
3171 auto ksp =
createKSP(m_field.get_comm());
3172 CHKERR KSPSetType(ksp, KSPPREONLY);
3174 CHKERR PCSetType(sub_pc, PCSHELL);
3177 CHKERR KSPSetPC(ksp, sub_pc);
3178 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:
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.
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.
Problem manager is used to build and partition problems.
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)
PipelineManager interface.
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.
Simple interface for fast problem set-up.
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
Calculate directional derivative of the right hand side and compare it with tangent matrix derivative...
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)