v0.15.0
Loading...
Searching...
No Matches
Classes | Macros | Typedefs | Enumerations | Functions | Variables
thermoplastic.cpp File Reference
#include <MoFEM.hpp>
#include <MatrixFunction.hpp>
#include <IntegrationRules.hpp>
#include <cstdlib>
#include <phg-quadrule/quad.h>
#include <HenckyOps.hpp>
#include <PlasticOps.hpp>
#include <PlasticNaturalBCs.hpp>
#include <ThermoElasticOps.hpp>
#include <FiniteThermalOps.hpp>
#include <ThermoPlasticOps.hpp>
#include <ThermalOps.hpp>
#include <EdgeFlippingOps.hpp>
#include <SolutionMapping.hpp>
#include <ThermalConvection.hpp>
#include <ThermalRadiation.hpp>

Go to the source code of this file.

Classes

struct  ElementsAndOps< 2 >
 
struct  ElementsAndOps< 3 >
 
struct  TSPrePostProc
 Set of functions called by PETSc solver used to refine and update mesh. More...
 
struct  ResizeCtx
 
struct  Example
 [Example] More...
 
struct  Example::ScaledTimeScale
 
struct  SetUpSchur
 [Push operators to pipeline] More...
 
struct  MyTsCtx
 
struct  SetUpSchurImpl
 

Macros

#define EXECUTABLE_DIMENSION   3
 

Typedefs

using EntData = EntitiesFieldData::EntData
 
using DomainEle = ElementsAndOps< SPACE_DIM >::DomainEle
 
using DomainEleOnRange = ElementsAndOps< SPACE_DIM >::DomainEleOnRange
 
using DomainEleOp = DomainEle::UserDataOperator
 
using BoundaryEle = ElementsAndOps< SPACE_DIM >::BoundaryEle
 
using BoundaryEleOp = BoundaryEle::UserDataOperator
 
using PostProcEle = PostProcBrokenMeshInMoab< DomainEle >
 
using SkinPostProcEle = PostProcBrokenMeshInMoab< BoundaryEle >
 
using SideEle = ElementsAndOps< SPACE_DIM >::SideEle
 
using SetPtsData = FieldEvaluatorInterface::SetPtsData
 
using AssemblyDomainEleOp = FormsIntegrators< DomainEleOp >::Assembly< AT >::OpBase
 
using ScalerFunTwoArgs = boost::function< double(const double, const double)>
 
using ScalerFunThreeArgs = boost::function< double(const double, const double, const double)>
 
using DomainRhsBCs = NaturalBC< DomainEleOp >::Assembly< AT >::LinearForm< IT >
 
using OpDomainRhsBCs = DomainRhsBCs::OpFlux< PlasticOps::DomainBCs, 1, SPACE_DIM >
 
using BoundaryRhsBCs = NaturalBC< BoundaryEleOp >::Assembly< AT >::LinearForm< IT >
 
using OpBoundaryRhsBCs = BoundaryRhsBCs::OpFlux< PlasticOps::BoundaryBCs, 1, SPACE_DIM >
 
using BoundaryLhsBCs = NaturalBC< BoundaryEleOp >::Assembly< AT >::BiLinearForm< IT >
 
using OpBoundaryLhsBCs = BoundaryLhsBCs::OpFlux< PlasticOps::BoundaryBCs, 1, SPACE_DIM >
 
using DomainNaturalBCRhs = NaturalBC< DomainEleOp >::Assembly< AT >::LinearForm< IT >
 [Body and heat source]
 
using OpBodyForce = DomainNaturalBCRhs::OpFlux< NaturalMeshsetType< BLOCKSET >, 1, SPACE_DIM >
 
using OpHeatSource = DomainNaturalBCRhs::OpFlux< NaturalMeshsetType< BLOCKSET >, 1, 1 >
 
using DomainNaturalBCLhs = NaturalBC< DomainEleOp >::Assembly< AT >::BiLinearForm< IT >
 
using BoundaryNaturalBC = NaturalBC< BoundaryEleOp >::Assembly< AT >::LinearForm< IT >
 [Body and heat source]
 
using OpForce = BoundaryNaturalBC::OpFlux< NaturalForceMeshsets, 1, SPACE_DIM >
 
using OpTemperatureBC = BoundaryNaturalBC::OpFlux< NaturalTemperatureMeshsets, 3, SPACE_DIM >
 
using OpEssentialFluxRhs = EssentialBC< BoundaryEleOp >::Assembly< AT >::LinearForm< IT >::OpEssentialRhs< HeatFluxCubitBcData, 3, SPACE_DIM >
 [Natural boundary conditions]
 
using OpEssentialFluxLhs = EssentialBC< BoundaryEleOp >::Assembly< AT >::BiLinearForm< IT >::OpEssentialLhs< HeatFluxCubitBcData, 3, SPACE_DIM >
 
using OpSetTemperatureRhs = DomainNaturalBCRhs::OpFlux< SetTargetTemperature, 1, 1 >
 [Essential boundary conditions (Least square approach)]
 
using OpSetTemperatureLhs = DomainNaturalBCLhs::OpFlux< SetTargetTemperature, 1, 1 >
 

Enumerations

enum  ICType { IC_UNIFORM , IC_GAUSSIAN , IC_LINEAR }
 
enum  ThermoPlasticityBits {
  COMPUTATION_BIT = 0 , FLIPPED_BIT = 1 , FIRST_REF_BIT = 2 , REFINED_EDGES_BIT = BITREFLEVEL_SIZE - 4 ,
  PREVIOUS_BIT = BITREFLEVEL_SIZE - 3 , VIRGIN_BIT = BITREFLEVEL_SIZE - 2 , STORAGE_BIT = BITREFLEVEL_SIZE - 1
}
 

Functions

double H_thermal (double H, double omega_h, double temp_0, double temp)
 
double dH_thermal_dtemp (double H, double omega_h)
 
double y_0_thermal (double sigmaY, double omega_0, double temp_0, double temp)
 
double dy_0_thermal_dtemp (double sigmaY, double omega_0)
 
double Qinf_thermal (double Qinf, double omega_h, double temp_0, double temp)
 
double dQinf_thermal_dtemp (double Qinf, double omega_h)
 
double iso_hardening_exp (double tau, double b_iso)
 
double temp_hat (double temp)
 
double exp_softening (double temp_hat)
 
double iso_hardening (double tau, double H, double omega_0, double Qinf, double omega_h, double b_iso, double sigmaY, double temp_0, double temp)
 
double iso_hardening_dtau (double tau, double H, double omega_0, double Qinf, double omega_h, double b_iso, double sigmaY, double temp_0, double temp)
 
double iso_hardening_dtemp (double tau, double H, double omega_0, double Qinf, double omega_h, double b_iso, double sigmaY, double temp_0, double temp)
 
template<typename T , int DIM>
auto kinematic_hardening (FTensor::Tensor2_symmetric< T, DIM > &t_plastic_strain, double C1_k)
 
template<int DIM>
auto kinematic_hardening_dplastic_strain (double C1_k)
 
auto postProcessHere (MoFEM::Interface &m_field, SmartPetscObj< DM > &dm, std::string output_name, int &counter= *(new int(0)))
 
auto postProcessPETScHere (MoFEM::Interface &m_field, SmartPetscObj< DM > &dm, Vec sol, std::string output_name)
 
auto printOnAllCores (MoFEM::Interface &m_field, const std::string &out_put_string, const auto &out_put_quantity)
 
PetscErrorCode MyTSResizeTransfer (TS, PetscInt, Vec[], Vec[], void *)
 
MoFEMErrorCode TSIterationPreStage (TS ts, PetscReal stagetime)
 
MoFEMErrorCode SNESIterationMonitor (SNES snes, PetscInt its, PetscReal norm, void *ctx)
 
PetscErrorCode MyTSResizeSetup (TS ts, PetscInt nstep, PetscReal time, Vec sol, PetscBool *resize, void *ctx)
 
int main (int argc, char *argv[])
 

Variables

constexpr int SPACE_DIM
 
constexpr auto size_symm = (SPACE_DIM * (SPACE_DIM + 1)) / 2
 
constexpr bool IS_LARGE_STRAINS
 
constexpr AssemblyType AT
 
constexpr IntegrationType IT
 
constexpr FieldSpace CONTACT_SPACE = ElementsAndOps<SPACE_DIM>::CONTACT_SPACE
 
double exp_C = -6.284
 
double exp_D = -1.024
 
const bool is_large_strains
 
PetscBool set_timer = PETSC_FALSE
 Set timer.
 
PetscBool do_eval_field = PETSC_FALSE
 Evaluate field.
 
char restart_file [255]
 
PetscBool restart_flg = PETSC_TRUE
 
double restart_time = 0
 
int restart_step = 0
 
PetscBool is_distributed_mesh = PETSC_TRUE
 
double scale = 1.
 
double default_thermal_conductivity_scale = 1.
 
double default_heat_capacity_scale = 1.
 
ScalerFunTwoArgs thermal_conductivity_scaling
 
ScalerFunTwoArgs heat_capacity_scaling
 
ScalerFunThreeArgs inelastic_heat_fraction_scaling
 
double young_modulus = 115000
 Young modulus.
 
double poisson_ratio = 0.31
 Poisson ratio.
 
double sigmaY = 936.2
 Yield stress.
 
double H = 584.3
 Hardening.
 
double visH = 0
 Viscous hardening.
 
double zeta = 5e-2
 regularisation parameter
 
double Qinf = 174.2
 Saturation yield stress.
 
double b_iso = 63.69
 Saturation exponent.
 
double C1_k = 0
 Kinematic hardening.
 
double cn0 = 1
 
double cn1 = 1
 
double default_ref_temp = 20.0
 
const char *const ICTypes []
 
ICType ic_type = IC_UNIFORM
 
double init_temp = 20.0
 
double peak_temp = 1000.0
 
double width = 10.0
 Width of Gaussian distribution.
 
double default_coeff_expansion = 1e-5
 
double default_heat_conductivity
 
double default_heat_capacity = 2.332
 
double omega_0 = 2e-3
 flow stress softening
 
double omega_h = 2e-3
 hardening softening
 
double inelastic_heat_fraction
 fraction of plastic dissipation converted to heat
 
double temp_0 = 20
 reference temperature for thermal softening
 
int order = 2
 Order displacement.
 
int tau_order = order - 2
 Order of tau field.
 
int ep_order = order - 1
 Order of ep field.
 
int flux_order = order
 Order of tau field.
 
int T_order = order - 1
 Order of ep field.
 
int geom_order = 2
 Order if fixed.
 
int atom_test = 0
 
PetscBool order_edge = PETSC_FALSE
 
PetscBool order_face = PETSC_FALSE
 
PetscBool order_volume = PETSC_FALSE
 
PetscBool is_quasi_static = PETSC_TRUE
 
double rho = 0.0
 
double alpha_damping = 0
 
double init_dt = 0.05
 
double min_dt = 1e-12
 
double qual_tol = 0
 
double qual_thresh = 0.1
 
double edge_growth_thresh = 0.2
 
int num_refinement_levels = 1
 
BitRefLevel comp_mesh_bit = BitRefLevel().set(COMPUTATION_BIT)
 
BitRefLevel flipped_bit = BitRefLevel().set(FLIPPED_BIT)
 
BitRefLevel refined_bit = BitRefLevel().set(FIRST_REF_BIT)
 
BitRefLevel prev_mesh_bit = BitRefLevel().set(PREVIOUS_BIT)
 
BitRefLevel virgin_mesh_bit = BitRefLevel().set(VIRGIN_BIT)
 
BitRefLevel storage_bit = BitRefLevel().set(STORAGE_BIT)
 
auto Gaussian_distribution
 
auto linear_distribution
 
auto uniform_distribution
 
auto init_T
 Initialisation function for temperature field.
 
int post_processing_counter = 0
 
auto save_range
 
auto get_string_from_vector
 
static boost::weak_ptr< TSPrePostProctsPrePostProc
 
static std::unordered_map< TS, ResizeCtx * > ts_to_rctx
 
static std::unordered_map< TS, MyTsCtx * > ts_to_ctx
 
Examplethermoplastic_raw_ptr = nullptr
 
static char help [] = "...\n\n"
 [Solve]
 

Macro Definition Documentation

◆ EXECUTABLE_DIMENSION

#define EXECUTABLE_DIMENSION   3

Definition at line 13 of file thermoplastic.cpp.

Typedef Documentation

◆ AssemblyDomainEleOp

Definition at line 76 of file thermoplastic.cpp.

◆ BoundaryEle

Definition at line 69 of file thermoplastic.cpp.

◆ BoundaryEleOp

Definition at line 70 of file thermoplastic.cpp.

◆ BoundaryLhsBCs

Definition at line 528 of file thermoplastic.cpp.

◆ BoundaryNaturalBC

[Body and heat source]

[Natural boundary conditions]

Definition at line 543 of file thermoplastic.cpp.

◆ BoundaryRhsBCs

Definition at line 525 of file thermoplastic.cpp.

◆ DomainEle

Definition at line 66 of file thermoplastic.cpp.

◆ DomainEleOnRange

Definition at line 67 of file thermoplastic.cpp.

◆ DomainEleOp

Definition at line 68 of file thermoplastic.cpp.

◆ DomainNaturalBCLhs

Definition at line 538 of file thermoplastic.cpp.

◆ DomainNaturalBCRhs

[Body and heat source]

Definition at line 533 of file thermoplastic.cpp.

◆ DomainRhsBCs

Definition at line 522 of file thermoplastic.cpp.

◆ EntData

Definition at line 65 of file thermoplastic.cpp.

◆ OpBodyForce

Definition at line 534 of file thermoplastic.cpp.

◆ OpBoundaryLhsBCs

using OpBoundaryLhsBCs = BoundaryLhsBCs::OpFlux<PlasticOps::BoundaryBCs, 1, SPACE_DIM>

Definition at line 529 of file thermoplastic.cpp.

◆ OpBoundaryRhsBCs

using OpBoundaryRhsBCs = BoundaryRhsBCs::OpFlux<PlasticOps::BoundaryBCs, 1, SPACE_DIM>

Definition at line 526 of file thermoplastic.cpp.

◆ OpDomainRhsBCs

using OpDomainRhsBCs = DomainRhsBCs::OpFlux<PlasticOps::DomainBCs, 1, SPACE_DIM>

Definition at line 523 of file thermoplastic.cpp.

◆ OpEssentialFluxLhs

Definition at line 553 of file thermoplastic.cpp.

◆ OpEssentialFluxRhs

[Natural boundary conditions]

[Essential boundary conditions (Least square approach)]

Definition at line 551 of file thermoplastic.cpp.

◆ OpForce

Definition at line 545 of file thermoplastic.cpp.

◆ OpHeatSource

Definition at line 536 of file thermoplastic.cpp.

◆ OpSetTemperatureLhs

using OpSetTemperatureLhs = DomainNaturalBCLhs::OpFlux<SetTargetTemperature, 1, 1>

Definition at line 559 of file thermoplastic.cpp.

◆ OpSetTemperatureRhs

using OpSetTemperatureRhs = DomainNaturalBCRhs::OpFlux<SetTargetTemperature, 1, 1>

[Essential boundary conditions (Least square approach)]

Definition at line 557 of file thermoplastic.cpp.

◆ OpTemperatureBC

Definition at line 546 of file thermoplastic.cpp.

◆ PostProcEle

Definition at line 71 of file thermoplastic.cpp.

◆ ScalerFunThreeArgs

using ScalerFunThreeArgs = boost::function<double(const double, const double, const double)>

Definition at line 79 of file thermoplastic.cpp.

◆ ScalerFunTwoArgs

using ScalerFunTwoArgs = boost::function<double(const double, const double)>

Definition at line 78 of file thermoplastic.cpp.

◆ SetPtsData

Definition at line 74 of file thermoplastic.cpp.

◆ SideEle

Definition at line 73 of file thermoplastic.cpp.

◆ SkinPostProcEle

Definition at line 72 of file thermoplastic.cpp.

Enumeration Type Documentation

◆ ICType

enum ICType
Enumerator
IC_UNIFORM 
IC_GAUSSIAN 
IC_LINEAR 

Definition at line 217 of file thermoplastic.cpp.

@ IC_UNIFORM
@ IC_LINEAR
@ IC_GAUSSIAN

◆ ThermoPlasticityBits

Enumerator
COMPUTATION_BIT 
FLIPPED_BIT 
FIRST_REF_BIT 
REFINED_EDGES_BIT 
PREVIOUS_BIT 
VIRGIN_BIT 
STORAGE_BIT 

Definition at line 261 of file thermoplastic.cpp.

261 {
262 COMPUTATION_BIT = 0,
263 FLIPPED_BIT = 1,
264 FIRST_REF_BIT = 2,
269};
#define BITREFLEVEL_SIZE
max number of refinements
@ FLIPPED_BIT
@ FIRST_REF_BIT
@ REFINED_EDGES_BIT
@ STORAGE_BIT
@ PREVIOUS_BIT
@ VIRGIN_BIT
@ COMPUTATION_BIT

Function Documentation

◆ dH_thermal_dtemp()

double dH_thermal_dtemp ( double  H,
double  omega_h 
)
inline
Examples
thermoplastic.cpp.

Definition at line 86 of file thermoplastic.cpp.

86 {
87 return -H * omega_h;
88}
double H
Hardening.
double omega_h
hardening softening

◆ dQinf_thermal_dtemp()

double dQinf_thermal_dtemp ( double  Qinf,
double  omega_h 
)
inline
Examples
thermoplastic.cpp.

Definition at line 104 of file thermoplastic.cpp.

104 {
105 return -Qinf * omega_h;
106}
double Qinf
Saturation yield stress.

◆ dy_0_thermal_dtemp()

double dy_0_thermal_dtemp ( double  sigmaY,
double  omega_0 
)
inline
Examples
thermoplastic.cpp.

Definition at line 95 of file thermoplastic.cpp.

95 {
96 return -sigmaY * omega_0;
97}
double omega_0
flow stress softening
double sigmaY
Yield stress.

◆ exp_softening()

double exp_softening ( double  temp_hat)
inline
Examples
thermoplastic.cpp.

Definition at line 122 of file thermoplastic.cpp.

122 {
123 return std::exp(exp_C * pow(temp_hat, 2) + exp_D * temp_hat);
124}
double exp_D
double temp_hat(double temp)
double exp_C

◆ H_thermal()

double H_thermal ( double  H,
double  omega_h,
double  temp_0,
double  temp 
)
inline
Examples
thermoplastic.cpp.

Definition at line 82 of file thermoplastic.cpp.

82 {
83 return H * (1. - omega_h * (temp - temp_0));
84}
void temp(int x, int y=10)
Definition simple.cpp:4
double temp_0
reference temperature for thermal softening

◆ iso_hardening()

double iso_hardening ( double  tau,
double  H,
double  omega_0,
double  Qinf,
double  omega_h,
double  b_iso,
double  sigmaY,
double  temp_0,
double  temp 
)
inline

Isotropic hardening

Definition at line 129 of file thermoplastic.cpp.

131 {
132 return (sigmaY + H * tau + Qinf * (1. - iso_hardening_exp(tau, b_iso))) *
134}
double exp_softening(double temp_hat)
double iso_hardening_exp(double tau, double b_iso)
double b_iso
Saturation exponent.

◆ iso_hardening_dtau()

double iso_hardening_dtau ( double  tau,
double  H,
double  omega_0,
double  Qinf,
double  omega_h,
double  b_iso,
double  sigmaY,
double  temp_0,
double  temp 
)
inline

Definition at line 136 of file thermoplastic.cpp.

138 {
139 return (H + Qinf * b_iso * iso_hardening_exp(tau, b_iso)) *
141}

◆ iso_hardening_dtemp()

double iso_hardening_dtemp ( double  tau,
double  H,
double  omega_0,
double  Qinf,
double  omega_h,
double  b_iso,
double  sigmaY,
double  temp_0,
double  temp 
)
inline
Examples
PlasticOpsGeneric.hpp, and thermoplastic.cpp.

Definition at line 143 of file thermoplastic.cpp.

145 {
146 double JC_ref_temp = 0.;
147 double JC_melt_temp = 1650.;
148 double T_hat = temp_hat(temp);
149
150 return (sigmaY + H * tau + Qinf * (1. - iso_hardening_exp(tau, b_iso))) *
151 (exp_D + 2 * T_hat * exp_C) *
152 std::exp(exp_D * T_hat + pow(T_hat, 2) * exp_C) /
153 (JC_melt_temp - JC_ref_temp);
154}

◆ iso_hardening_exp()

double iso_hardening_exp ( double  tau,
double  b_iso 
)
inline

Definition at line 108 of file thermoplastic.cpp.

108 {
109 return std::exp(-b_iso * tau);
110}

◆ kinematic_hardening()

template<typename T , int DIM>
auto kinematic_hardening ( FTensor::Tensor2_symmetric< T, DIM > &  t_plastic_strain,
double  C1_k 
)
inline

Kinematic hardening

Definition at line 161 of file thermoplastic.cpp.

162 {
163 FTensor::Index<'i', DIM> i;
164 FTensor::Index<'j', DIM> j;
166 if (C1_k < std::numeric_limits<double>::epsilon()) {
167 t_alpha(i, j) = 0;
168 return t_alpha;
169 }
170 t_alpha(i, j) = C1_k * t_plastic_strain(i, j);
171 return t_alpha;
172}
FTensor::Index< 'i', SPACE_DIM > i
FTensor::Index< 'j', 3 > j
double C1_k
Kinematic hardening.

◆ kinematic_hardening_dplastic_strain()

template<int DIM>
auto kinematic_hardening_dplastic_strain ( double  C1_k)
inline

Definition at line 175 of file thermoplastic.cpp.

175 {
176 FTensor::Index<'i', DIM> i;
177 FTensor::Index<'j', DIM> j;
178 FTensor::Index<'k', DIM> k;
179 FTensor::Index<'l', DIM> l;
182 t_diff(i, j, k, l) = C1_k * (t_kd(i, k) ^ t_kd(j, l)) / 4.;
183 return t_diff;
184}
Kronecker Delta class symmetric.
constexpr auto t_kd
FTensor::Index< 'l', 3 > l
FTensor::Index< 'k', 3 > k

◆ main()

int main ( int  argc,
char *  argv[] 
)

[Register MoFEM discrete manager in PETSc]

[Register MoFEM discrete manager in PETSc

[Create MoAB]

< mesh database

< mesh database interface

[Create MoAB]

[Create MoFEM]

< finite element database

< finite element database interface

[Create MoFEM]

[Load mesh]

[Load mesh]

[Example]

[Example]

Definition at line 5663 of file thermoplastic.cpp.

5663 {
5664
5665#ifdef ADD_CONTACT
5666 #ifdef ENABLE_PYTHON_BINDING
5667 Py_Initialize();
5668 np::initialize();
5669 #endif
5670#endif // ADD_CONTACT
5671
5672 // Initialisation of MoFEM/PETSc and MOAB data structures
5673 const char param_file[] = "param_file.petsc";
5674 MoFEM::Core::Initialize(&argc, &argv, param_file, help);
5675
5676 // Add logging channel for example
5677 auto core_log = logging::core::get();
5678 core_log->add_sink(
5680 core_log->add_sink(
5682 core_log->add_sink(
5683 LogManager::createSink(LogManager::getStrmWorld(), "THERMOPLASTICITY"));
5684 core_log->add_sink(
5686 core_log->add_sink(
5688 LogManager::setLog("PLASTICITY");
5689 LogManager::setLog("THERMAL");
5690 LogManager::setLog("THERMOPLASTICITY");
5691 LogManager::setLog("REMESHING");
5692 MOFEM_LOG_TAG("PLASTICITY", "Plasticity");
5693 MOFEM_LOG_TAG("THERMAL", "Thermal");
5694 MOFEM_LOG_TAG("THERMOPLASTICITY", "Thermoplasticity");
5695 MOFEM_LOG_TAG("REMESHING", "Remeshing");
5696
5697#ifdef ADD_CONTACT
5698 core_log->add_sink(
5700 LogManager::setLog("CONTACT");
5701 MOFEM_LOG_TAG("CONTACT", "Contact");
5702#endif // ADD_CONTACT
5703
5704 try {
5705
5706 //! [Register MoFEM discrete manager in PETSc]
5707 DMType dm_name = "DMMOFEM";
5708 CHKERR DMRegister_MoFEM(dm_name);
5709 //! [Register MoFEM discrete manager in PETSc
5710
5711 //! [Create MoAB]
5712 moab::Core mb_instance; ///< mesh database
5713 moab::Interface &moab = mb_instance; ///< mesh database interface
5714 //! [Create MoAB]
5715
5716 //! [Create MoFEM]
5717 MoFEM::Core core(moab); ///< finite element database
5718 MoFEM::Interface &m_field = core; ///< finite element database interface
5719 //! [Create MoFEM]
5720
5721 //! [Load mesh]
5722 Simple *simple = m_field.getInterface<Simple>();
5724
5725 simple->getBitRefLevel() = comp_mesh_bit;
5726 simple->getBitRefLevelMask() = BitRefLevel().set();
5727
5728 CHKERR PetscOptionsGetBool(PETSC_NULLPTR, "", "-is_distributed_mesh",
5729 &is_distributed_mesh, PETSC_NULLPTR);
5730 if (is_distributed_mesh == PETSC_TRUE) {
5731 CHKERR simple->loadFile();
5732 } else {
5733 char meshFileName[255];
5734 CHKERR PetscOptionsGetString(PETSC_NULLPTR, PETSC_NULLPTR, "-file_name",
5735 meshFileName, 255, PETSC_NULLPTR);
5736 CHKERR simple->loadFile("", meshFileName);
5737 }
5738
5739 Range ents;
5740 CHKERR m_field.get_moab().get_entities_by_dimension(0, SPACE_DIM, ents,
5741 true);
5742 CHKERR m_field.getInterface<BitRefManager>()->setBitRefLevel(
5744 false);
5745 //! [Load mesh]
5746
5747 //! [Example]
5748 Example ex(m_field);
5749 CHKERR ex.runProblem();
5750 //! [Example]
5751 }
5753
5755
5756#ifdef ADD_CONTACT
5757 #ifdef ENABLE_PYTHON_BINDING
5758 if (Py_FinalizeEx() < 0) {
5759 exit(120);
5760 }
5761 #endif
5762#endif // ADD_CONTACT
5763
5764 return 0;
5765}
void simple(double P1[], double P2[], double P3[], double c[], const int N)
Definition acoustic.cpp:69
#define CATCH_ERRORS
Catch errors.
#define CHKERR
Inline error check.
PetscErrorCode DMRegister_MoFEM(const char sname[])
Register MoFEM problem.
Definition DMMoFEM.cpp:43
static LoggerType & setLog(const std::string channel)
Set ans resset chanel logger.
#define MOFEM_LOG_TAG(channel, tag)
Tag channel.
std::bitset< BITREFLEVEL_SIZE > BitRefLevel
Bit structure attached to each entity identifying to what mesh entity is attached.
Definition Types.hpp:40
PetscErrorCode PetscOptionsGetBool(PetscOptions *, const char pre[], const char name[], PetscBool *bval, PetscBool *set)
PetscErrorCode PetscOptionsGetString(PetscOptions *, const char pre[], const char name[], char str[], size_t size, PetscBool *set)
[Example]
Definition plastic.cpp:216
Managing BitRefLevels.
virtual moab::Interface & get_moab()=0
Core (interface) class.
Definition Core.hpp:82
static MoFEMErrorCode Initialize(int *argc, char ***args, const char file[], const char help[])
Initializes the MoFEM database PETSc, MOAB and MPI.
Definition Core.cpp:72
static MoFEMErrorCode Finalize()
Checks for options to be called at the conclusion of the program.
Definition Core.cpp:118
Deprecated interface functions.
static boost::shared_ptr< SinkType > createSink(boost::shared_ptr< std::ostream > stream_ptr, std::string comm_filter)
Create a sink object.
static boost::shared_ptr< std::ostream > getStrmWorld()
Get the strm world object.
Simple interface for fast problem set-up.
Definition Simple.hpp:27
MoFEMErrorCode getOptions()
get options
Definition Simple.cpp:180
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.
static char help[]
[Solve]
BitRefLevel storage_bit
PetscBool is_distributed_mesh
constexpr int SPACE_DIM
BitRefLevel virgin_mesh_bit
BitRefLevel comp_mesh_bit
BitRefLevel prev_mesh_bit

◆ MyTSResizeSetup()

PetscErrorCode MyTSResizeSetup ( TS  ts,
PetscInt  nstep,
PetscReal  time,
Vec  sol,
PetscBool *  resize,
void *  ctx 
)
Examples
thermoplastic.cpp.

Definition at line 4142 of file thermoplastic.cpp.

4143 {
4144 PetscFunctionBegin;
4145 ResizeCtx *rctx = static_cast<ResizeCtx *>(ctx);
4146 *resize = rctx->mesh_changed;
4147 PetscFunctionReturn(0);
4148}
PetscBool mesh_changed

◆ MyTSResizeTransfer()

PetscErrorCode MyTSResizeTransfer ( TS  ts,
PetscInt  nv,
Vec  ts_vecsin[],
Vec  ts_vecsout[],
void *  ctx 
)
extern
Examples
thermoplastic.cpp.

Definition at line 4150 of file thermoplastic.cpp.

4151 {
4152 PetscFunctionBegin;
4153 ResizeCtx *rctx = static_cast<ResizeCtx *>(ctx);
4154
4155 if (auto ptr = rctx->ptr.lock()) {
4156
4157 MoFEM::Interface &m_field = *(rctx->m_field);
4158
4159 auto bit_mng = m_field.getInterface<BitRefManager>();
4160
4161 auto set_prev_mesh_bit = [](EntityHandle ent, BitRefLevel &bit) {
4162 if (bit[COMPUTATION_BIT]) {
4163 bit.set(COMPUTATION_BIT, false);
4164 bit.set(PREVIOUS_BIT, true);
4165 }
4166 };
4167
4168 CHKERR bit_mng->lambdaBitRefLevel(set_prev_mesh_bit);
4169
4170 std::string improved_reasons = "";
4171
4172 Range edges_to_not_refine;
4173
4174 CHKERR ptr->ExRawPtr->doEdgeFlips(rctx->el_q_map, rctx->flipped_els,
4175 rctx->th_spatial_coords,
4176 rctx->new_connectivity);
4177 if (rctx->el_q_map.size() > 0) {
4178 improved_reasons += ", Edge flipping";
4179 }
4180
4181 bool refined = false;
4182 int step;
4183 CHKERR TSGetStepNumber(ts, &step);
4184 CHKERR ptr->ExRawPtr->doEdgeSplits(refined, (step) ? true : false);
4185 if (refined) {
4186 improved_reasons += ", Edge splitting";
4187 }
4188
4189 // Erase leading ", " from improved_reasons
4190 improved_reasons.erase(0, 2);
4191
4192 if (improved_reasons != "")
4193 MOFEM_LOG("REMESHING", Sev::inform)
4194 << "Improved mesh quality by: " << improved_reasons;
4195
4196#ifndef NDEBUG
4197
4198 // comp_mesh_bit = BitRefLevel().set(COMPUTATION_BIT);
4199 // flipped_bit = BitRefLevel().set(FLIPPED_BIT);
4200 // refined_bit = BitRefLevel().set(FIRST_REF_BIT);
4201 // prev_mesh_bit = BitRefLevel().set(PREVIOUS_BIT);
4202 // virgin_mesh_bit = BitRefLevel().set(VIRGIN_BIT);
4203 // storage_bit = BitRefLevel().set(STORAGE_BIT);
4204
4205 if (m_field.get_comm_rank() == 0) {
4206 CHKERR m_field.getInterface<BitRefManager>()->writeBitLevelByDim(
4207 comp_mesh_bit, BitRefLevel().set(), 2,
4208 "before_mapping_comp_mesh_bit.vtk", "VTK", "");
4209 CHKERR m_field.getInterface<BitRefManager>()->writeBitLevelByDim(
4210 flipped_bit, BitRefLevel().set(), 2, "before_mapping_flipped_bit.vtk",
4211 "VTK", "");
4212 CHKERR m_field.getInterface<BitRefManager>()->writeBitLevelByDim(
4213 refined_bit, BitRefLevel().set(), 2, "before_mapping_refined_bit.vtk",
4214 "VTK", "");
4215 CHKERR m_field.getInterface<BitRefManager>()->writeBitLevelByDim(
4216 prev_mesh_bit, BitRefLevel().set(), 2,
4217 "before_mapping_prev_mesh_bit.vtk", "VTK", "");
4218 CHKERR m_field.getInterface<BitRefManager>()->writeBitLevelByDim(
4219 virgin_mesh_bit, BitRefLevel().set(), 2,
4220 "before_mapping_virgin_mesh_bit.vtk", "VTK", "");
4221 }
4222#endif // NDEBUG
4223
4224 MOFEM_LOG("REMESHING", Sev::verbose) << "number of vectors to map = " << nv;
4225
4226 for (PetscInt i = 0; i < nv; ++i) {
4227 double nrm;
4228 CHKERR VecNorm(ts_vecsin[i], NORM_2, &nrm);
4229 MOFEM_LOG("REMESHING", Sev::warning)
4230 << "Before remeshing: ts_vecsin[" << i << "] norm = " << nrm;
4231 }
4232
4233 auto scatter_mng = m_field.getInterface<VecManager>();
4234 auto simple = m_field.getInterface<Simple>();
4235
4236 // CHKERR m_field.getInterface<BitRefManager>()->writeBitLevel(
4237 // BitRefLevel().set(1), BitRefLevel().set(), "before_resettingup.vtk",
4238 // "VTK", "");
4239
4240 // Rebuilding DM with old and new mesh entities
4241 auto bit = BitRefLevel().set();
4243 {"TAU", "EP", "T"}, {tau_order, ep_order, T_order}, {"U"},
4244 {order}, {"FLUX"}, {flux_order}, bit);
4245
4246 // CHKERR m_field.getInterface<BitRefManager>()->writeBitLevel(
4247 // BitRefLevel().set(1), BitRefLevel().set(), "after_resettingup.vtk",
4248 // "VTK", "");
4249
4250 auto intermediate_dm = createDM(m_field.get_comm(), "DMMOFEM");
4252 intermediate_dm, &m_field, "INTERMEDIATE_DM",
4254 BitRefLevel().set());
4255 CHKERR DMMoFEMSetDestroyProblem(intermediate_dm, PETSC_TRUE);
4256 CHKERR DMSetFromOptions(intermediate_dm);
4257 CHKERR DMMoFEMAddElement(intermediate_dm, simple->getDomainFEName());
4258 CHKERR DMMoFEMSetSquareProblem(intermediate_dm, PETSC_TRUE);
4260 CHKERR DMSetUp(intermediate_dm);
4261
4262 Vec vec_in[nv], vec_out[nv];
4263 for (PetscInt i = 0; i < nv; ++i) {
4264 CHKERR DMCreateGlobalVector(intermediate_dm, &vec_in[i]);
4265 CHKERR VecDuplicate(vec_in[i], &vec_out[i]);
4266 }
4267
4268 VecScatter scatter_to_intermediate;
4269
4270 for (PetscInt i = 0; i < nv; ++i) {
4271 CHKERR scatter_mng->vecScatterCreate(
4272 ts_vecsin[i], simple->getProblemName(), RowColData::ROW, vec_in[i],
4273 "INTERMEDIATE_DM", RowColData::ROW, &scatter_to_intermediate);
4274 CHKERR VecScatterBegin(scatter_to_intermediate, ts_vecsin[i], vec_in[i],
4275 INSERT_VALUES, SCATTER_FORWARD);
4276 CHKERR VecScatterEnd(scatter_to_intermediate, ts_vecsin[i], vec_in[i],
4277 INSERT_VALUES, SCATTER_FORWARD);
4278 }
4279
4280 CHKERR VecScatterDestroy(&scatter_to_intermediate);
4281
4283 intermediate_dm, prev_mesh_bit,
4284 BitRefLevel().set(FLIPPED_BIT + num_refinement_levels), nv, vec_in,
4285 vec_out);
4286
4287 // Build problem on new bit ref level
4288 auto ts_problem_name = simple->getProblemName();
4290 ts_problem_name,
4292 CHKERR m_field.modify_problem_mask_ref_level_set_bit(ts_problem_name,
4293 BitRefLevel().set());
4295 PetscBarrier(nullptr);
4296 CHKERR DMSetUp_MoFEM(simple->getDM());
4297
4298 // Update meshsets for correct BCs
4299 MeshsetsManager *meshsets_manager_ptr;
4300 CHKERR m_field.getInterface(meshsets_manager_ptr);
4301 CHKERR meshsets_manager_ptr->updateAllMeshsetsByEntitiesChildren(
4302 BitRefLevel().set());
4303
4304 CHKERR ptr->ExRawPtr->mechanicalBC();
4305 CHKERR ptr->ExRawPtr->thermalBC();
4306
4307 VecScatter scatter_to_final;
4308
4309 for (PetscInt i = 0; i < nv; ++i) {
4310 CHKERR DMCreateGlobalVector(simple->getDM(), &ts_vecsout[i]);
4311 CHKERR scatter_mng->vecScatterCreate(
4312 ts_vecsout[i], simple->getProblemName(), RowColData::ROW, vec_out[i],
4313 "INTERMEDIATE_DM", RowColData::ROW, &scatter_to_final);
4314 CHKERR VecScatterBegin(scatter_to_final, vec_out[i], ts_vecsout[i],
4315 INSERT_VALUES, SCATTER_REVERSE);
4316 CHKERR VecScatterEnd(scatter_to_final, vec_out[i], ts_vecsout[i],
4317 INSERT_VALUES, SCATTER_REVERSE);
4318 CHKERR VecScatterDestroy(&scatter_to_final);
4319 }
4320
4321 for (PetscInt i = 0; i < nv; ++i) {
4322 CHKERR VecDestroy(&vec_in[i]);
4323 CHKERR VecDestroy(&vec_out[i]);
4324 }
4325
4326 auto set_all_bit = [&](EntityHandle ent, BitRefLevel &bit) {
4327 for (auto l = 0; l <= FLIPPED_BIT + num_refinement_levels; ++l) {
4328 bit.set(STORAGE_BIT, true);
4329 }
4330 if (bit[VIRGIN_BIT]) {
4331 bit.set(VIRGIN_BIT, false);
4332 }
4333 if (bit[FLIPPED_BIT]) {
4334 bit.set(VIRGIN_BIT, true);
4335 }
4336 if (bit[PREVIOUS_BIT]) {
4337 bit.set(PREVIOUS_BIT, false);
4338 }
4340 bit.set(COMPUTATION_BIT, true);
4341 }
4342 };
4343 CHKERR bit_mng->lambdaBitRefLevel(set_all_bit);
4344
4345#ifndef NDEBUG
4346
4347 // comp_mesh_bit = BitRefLevel().set(COMPUTATION_BIT);
4348 // flipped_bit = BitRefLevel().set(FLIPPED_BIT);
4349 // refined_bit = BitRefLevel().set(FIRST_REF_BIT);
4350 // prev_mesh_bit = BitRefLevel().set(PREVIOUS_BIT);
4351 // virgin_mesh_bit = BitRefLevel().set(VIRGIN_BIT);
4352 // storage_bit = BitRefLevel().set(STORAGE_BIT);
4353
4354 if (m_field.get_comm_rank() == 0) {
4355 CHKERR m_field.getInterface<BitRefManager>()->writeBitLevelByDim(
4356 comp_mesh_bit, BitRefLevel().set(), 2,
4357 "after_mapping_comp_mesh_bit.vtk", "VTK", "");
4358 CHKERR m_field.getInterface<BitRefManager>()->writeBitLevelByDim(
4359 flipped_bit, BitRefLevel().set(), 2, "after_mapping_flipped_bit.vtk",
4360 "VTK", "");
4361 CHKERR m_field.getInterface<BitRefManager>()->writeBitLevelByDim(
4362 refined_bit, BitRefLevel().set(), 2, "after_mapping_refined_bit.vtk",
4363 "VTK", "");
4364 CHKERR m_field.getInterface<BitRefManager>()->writeBitLevelByDim(
4365 prev_mesh_bit, BitRefLevel().set(), 2,
4366 "after_mapping_prev_mesh_bit.vtk", "VTK", "");
4367 CHKERR m_field.getInterface<BitRefManager>()->writeBitLevelByDim(
4368 virgin_mesh_bit, BitRefLevel().set(), 2,
4369 "after_mapping_virgin_mesh_bit.vtk", "VTK", "");
4370 }
4371#endif // NDEBUG
4372
4373 CHKERR m_field.modify_problem_ref_level_set_bit(ts_problem_name,
4375 CHKERR m_field.modify_problem_mask_ref_level_set_bit(ts_problem_name,
4376 BitRefLevel().set());
4377
4378 CHKERR TSSetDM(ts, simple->getDM());
4379
4380 auto B = createDMMatrix(simple->getDM());
4381 CHKERR TSSetIJacobian(ts, B, B, nullptr, nullptr);
4382 }
4383
4384 for (PetscInt i = 0; i < nv; ++i) {
4385 double nrm;
4386 CHKERR VecNorm(ts_vecsout[i], NORM_2, &nrm);
4387 MOFEM_LOG("REMESHING", Sev::warning)
4388 << "After remeshing: ts_vecsout[" << i << "] norm = " << nrm;
4389 }
4390
4391 PetscFunctionReturn(0);
4392}
@ ROW
PetscErrorCode DMMoFEMSetIsPartitioned(DM dm, PetscBool is_partitioned)
Definition DMMoFEM.cpp:1113
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 DMMoFEMCreateMoFEM(DM dm, MoFEM::Interface *m_field_ptr, const char problem_name[], const MoFEM::BitRefLevel bit_level, const MoFEM::BitRefLevel bit_mask=MoFEM::BitRefLevel().set())
Must be called by user to set MoFEM data structures.
Definition DMMoFEM.cpp:114
auto createDMMatrix(DM dm)
Get smart matrix from DM.
Definition DMMoFEM.hpp:1191
PetscErrorCode DMSetUp_MoFEM(DM dm)
Definition DMMoFEM.cpp:1297
MoFEMErrorCode lambdaBitRefLevel(boost::function< void(EntityHandle ent, BitRefLevel &bit)> fun) const
Process bit ref level by lambda function.
#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
const FTensor::Tensor2< T, Dim, Dim > Vec
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.
virtual MPI_Comm & get_comm() const =0
virtual int get_comm_rank() const =0
Interface for managing meshsets containing materials and boundary conditions.
MoFEMErrorCode updateAllMeshsetsByEntitiesChildren(const BitRefLevel &bit)
Update all blocksets, sidesets and node sets.
Vector manager is used to create vectors \mofem_vectors.
boost::weak_ptr< TSPrePostProc > ptr
MoFEM::Interface * m_field
std::vector< EntityHandle > new_connectivity
std::multimap< double, EntityHandle > el_q_map
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)
BitRefLevel flipped_bit
int flux_order
Order of tau field.
int T_order
Order of ep field.
int tau_order
Order of tau field.
int order
Order displacement.
BitRefLevel refined_bit
int num_refinement_levels
int ep_order
Order of ep field.

◆ postProcessHere()

auto postProcessHere ( MoFEM::Interface m_field,
SmartPetscObj< DM > &  dm,
std::string  output_name,
int &  counter = *(new int(0)) 
)
Examples
thermoplastic.cpp.

Definition at line 351 of file thermoplastic.cpp.

352 {
354
355 auto create_post_process_elements = [&]() {
357 auto pp_fe = boost::make_shared<PostProcEle>(m_field);
358
359 auto push_vol_post_proc_ops = [&](auto &pp_fe) {
361
362 auto &pip = pp_fe->getOpPtrVector();
363
364 auto TAU_ptr = boost::make_shared<VectorDouble>();
365 pip.push_back(new OpCalculateScalarFieldValues("TAU", TAU_ptr));
366 auto T_ptr = boost::make_shared<VectorDouble>();
367 pip.push_back(new OpCalculateScalarFieldValues("T", T_ptr));
368
369 auto T_grad_ptr = boost::make_shared<MatrixDouble>();
370 pip.push_back(
371 new OpCalculateScalarFieldGradient<SPACE_DIM>("T", T_grad_ptr));
372 auto U_ptr = boost::make_shared<MatrixDouble>();
373 pip.push_back(new OpCalculateVectorFieldValues<SPACE_DIM>("U", U_ptr));
374 auto FLUX_ptr = boost::make_shared<MatrixDouble>();
375 pip.push_back(
376 new OpCalculateHVecVectorField<3, SPACE_DIM>("FLUX", FLUX_ptr));
377
378 auto EP_ptr = boost::make_shared<MatrixDouble>();
379 pip.push_back(
381
383
384 pip.push_back(
385
386 new OpPPMap(
387
388 pp_fe->getPostProcMesh(), pp_fe->getMapGaussPts(),
389
390 {{"TAU", TAU_ptr}, {"T", T_ptr}},
391
392 {{"U", U_ptr}, {"FLUX", FLUX_ptr}, {"T_GRAD", T_grad_ptr}},
393
394 {},
395
396 {{"EP", EP_ptr}}
397
398 )
399
400 );
401
403 };
404
405 CHKERR push_vol_post_proc_ops(pp_fe);
406
407 if (m_field.get_comm_size() == 1) {
408
409 CHKERR DMoFEMLoopFiniteElements(dm, "dFE", pp_fe);
410 CHKERR pp_fe->writeFile("out_" + std::to_string(counter) + "_" +
411 output_name + ".h5m");
412 } else {
413
415 m_field.get_comm_size());
416 auto &post_proc_moab = pp_fe->getPostProcMesh();
417 auto file_name = "out_" + std::to_string(counter) + "_" + output_name +
418 "_" + std::to_string(m_field.get_comm_rank()) + ".vtk";
419 MOFEM_LOG("WORLD", Sev::inform)
420 << "Writing file " << file_name << std::endl;
421 CHKERR post_proc_moab.write_file(file_name.c_str(), "VTK");
422 }
423 counter++;
424
426 };
427
428 CHKERR create_post_process_elements();
429
431}
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
PetscErrorCode DMoFEMLoopFiniteElements(DM dm, const char fe_name[], MoFEM::FEMethod *method, CacheTupleWeakPtr cache_ptr=CacheTupleSharedPtr())
Executes FEMethod for finite elements in DM.
Definition DMMoFEM.cpp:576
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
OpPostProcMapInMoab< SPACE_DIM, SPACE_DIM > OpPPMap
virtual int get_comm_size() const =0
Get vector field for H-div approximation.
Get field gradients at integration pts for scalar field rank 0, i.e. vector field.
Specialization for double precision scalar field values calculation.
Calculate symmetric tensor field values at integration pts.
Specialization for double precision vector field values calculation.
Post post-proc data at points from hash maps.

◆ postProcessPETScHere()

auto postProcessPETScHere ( MoFEM::Interface m_field,
SmartPetscObj< DM > &  dm,
Vec  sol,
std::string  output_name 
)
Examples
thermoplastic.cpp.

Definition at line 433 of file thermoplastic.cpp.

434 {
436
437 auto smart_sol = SmartPetscObj<Vec>(sol, true);
438
439 auto create_post_process_elements = [&]() {
441 auto pp_fe = boost::make_shared<PostProcEle>(m_field);
442
443 auto push_vol_post_proc_ops = [&](auto &pp_fe) {
445
446 auto &pip = pp_fe->getOpPtrVector();
447
448 auto TAU_ptr = boost::make_shared<VectorDouble>();
449 pip.push_back(
450 new OpCalculateScalarFieldValues("TAU", TAU_ptr, smart_sol));
451 auto T_ptr = boost::make_shared<VectorDouble>();
452 pip.push_back(new OpCalculateScalarFieldValues("T", T_ptr, smart_sol));
453
454 auto U_ptr = boost::make_shared<MatrixDouble>();
455 pip.push_back(
456 new OpCalculateVectorFieldValues<SPACE_DIM>("U", U_ptr, smart_sol));
457 auto FLUX_ptr = boost::make_shared<MatrixDouble>();
459 "FLUX", FLUX_ptr, smart_sol));
460
461 auto EP_ptr = boost::make_shared<MatrixDouble>();
463 "EP", EP_ptr, smart_sol));
464
466
467 pip.push_back(
468
469 new OpPPMap(
470
471 pp_fe->getPostProcMesh(), pp_fe->getMapGaussPts(),
472
473 {{"TAU", TAU_ptr}, {"T", T_ptr}},
474
475 {{"U", U_ptr}, {"FLUX", FLUX_ptr}},
476
477 {},
478
479 {{"EP", EP_ptr}}
480
481 )
482
483 );
484
486 };
487
488 CHKERR push_vol_post_proc_ops(pp_fe);
489
490 CHKERR DMoFEMLoopFiniteElements(dm, "dFE", pp_fe);
491 CHKERR pp_fe->writeFile("out_" + output_name + ".h5m");
492
494 };
495
496 CHKERR create_post_process_elements();
497
499}
intrusive_ptr for managing petsc objects

◆ printOnAllCores()

auto printOnAllCores ( MoFEM::Interface m_field,
const std::string &  out_put_string,
const auto &  out_put_quantity 
)
Examples
thermoplastic.cpp.

Definition at line 501 of file thermoplastic.cpp.

503 {
505 auto rank = m_field.get_comm_rank();
506 auto size = m_field.get_comm_size();
507
508 // Loop through all processes and print one by one
509 for (int i = 0; i < size; ++i) {
510 // If it is this process's turn, print the data
511 if (i == rank) {
512 std::cout << "Proc " << rank << " " + out_put_string + " "
513 << out_put_quantity << std::endl;
514 }
515 // All processes wait here until the current one has finished
516 // printing
517 CHKERR PetscBarrier(NULL);
518 }
520};

◆ Qinf_thermal()

double Qinf_thermal ( double  Qinf,
double  omega_h,
double  temp_0,
double  temp 
)
inline
Examples
thermoplastic.cpp.

Definition at line 99 of file thermoplastic.cpp.

100 {
101 return Qinf * (1. - omega_h * (temp - temp_0));
102}

◆ SNESIterationMonitor()

MoFEMErrorCode SNESIterationMonitor ( SNES  snes,
PetscInt  its,
PetscReal  norm,
void *  ctx 
)
Examples
thermoplastic.cpp.

Definition at line 4134 of file thermoplastic.cpp.

4135 {
4137 MyTsCtx *my_ctx = static_cast<MyTsCtx *>(ctx);
4138 my_ctx->snes_iter_counter++;
4140}
PetscInt snes_iter_counter

◆ temp_hat()

double temp_hat ( double  temp)
inline
Examples
thermoplastic.cpp.

Definition at line 115 of file thermoplastic.cpp.

115 {
116 double JC_ref_temp = 0.;
117 double JC_melt_temp = 1650.;
118
119 return (temp - JC_ref_temp) / (JC_melt_temp - JC_ref_temp);
120}

◆ TSIterationPreStage()

MoFEMErrorCode TSIterationPreStage ( TS  ts,
PetscReal  stagetime 
)
Examples
thermoplastic.cpp.

Definition at line 4126 of file thermoplastic.cpp.

4126 {
4128 MyTsCtx *my_ctx = ts_to_ctx[ts];
4129 my_ctx->snes_iter_counter = 0;
4131}
static std::unordered_map< TS, MyTsCtx * > ts_to_ctx

◆ y_0_thermal()

double y_0_thermal ( double  sigmaY,
double  omega_0,
double  temp_0,
double  temp 
)
inline
Examples
thermoplastic.cpp.

Definition at line 90 of file thermoplastic.cpp.

91 {
92 return sigmaY * (1. - omega_0 * (temp - temp_0));
93}

Variable Documentation

◆ alpha_damping

double alpha_damping = 0

Definition at line 253 of file thermoplastic.cpp.

◆ AT

constexpr AssemblyType AT
constexpr
Initial value:
=
(SCHUR_ASSEMBLE) ? AssemblyType::BLOCK_SCHUR
AssemblyType
[Storage and set boundary conditions]
@ PETSC
Standard PETSc assembly.
#define SCHUR_ASSEMBLE
Definition contact.cpp:18
Examples
thermoplastic.cpp.

Definition at line 55 of file thermoplastic.cpp.

◆ atom_test

int atom_test = 0

Definition at line 245 of file thermoplastic.cpp.

◆ b_iso

double b_iso = 63.69

Saturation exponent.

Definition at line 210 of file thermoplastic.cpp.

◆ C1_k

double C1_k = 0

Kinematic hardening.

Definition at line 211 of file thermoplastic.cpp.

◆ cn0

double cn0 = 1

Definition at line 213 of file thermoplastic.cpp.

◆ cn1

double cn1 = 1

Definition at line 214 of file thermoplastic.cpp.

◆ comp_mesh_bit

BitRefLevel comp_mesh_bit = BitRefLevel().set(COMPUTATION_BIT)
Examples
thermoplastic.cpp.

Definition at line 271 of file thermoplastic.cpp.

◆ CONTACT_SPACE

constexpr FieldSpace CONTACT_SPACE = ElementsAndOps<SPACE_DIM>::CONTACT_SPACE
constexpr

Definition at line 63 of file thermoplastic.cpp.

◆ default_coeff_expansion

double default_coeff_expansion = 1e-5

Definition at line 225 of file thermoplastic.cpp.

◆ default_heat_capacity

double default_heat_capacity = 2.332

Definition at line 229 of file thermoplastic.cpp.

◆ default_heat_capacity_scale

double default_heat_capacity_scale = 1.
Examples
thermoplastic.cpp.

Definition at line 198 of file thermoplastic.cpp.

◆ default_heat_conductivity

double default_heat_conductivity
Initial value:
=
11.4

Definition at line 226 of file thermoplastic.cpp.

◆ default_ref_temp

double default_ref_temp = 20.0

Definition at line 216 of file thermoplastic.cpp.

◆ default_thermal_conductivity_scale

double default_thermal_conductivity_scale = 1.
Examples
ThermoElasticOps.hpp, and thermoplastic.cpp.

Definition at line 197 of file thermoplastic.cpp.

◆ do_eval_field

PetscBool do_eval_field = PETSC_FALSE

Evaluate field.

Definition at line 189 of file thermoplastic.cpp.

◆ edge_growth_thresh

double edge_growth_thresh = 0.2
Examples
thermoplastic.cpp.

Definition at line 258 of file thermoplastic.cpp.

◆ ep_order

int ep_order = order - 1

Order of ep field.

Definition at line 240 of file thermoplastic.cpp.

◆ exp_C

double exp_C = -6.284
Examples
thermoplastic.cpp.

Definition at line 112 of file thermoplastic.cpp.

◆ exp_D

double exp_D = -1.024
Examples
thermoplastic.cpp.

Definition at line 113 of file thermoplastic.cpp.

◆ flipped_bit

BitRefLevel flipped_bit = BitRefLevel().set(FLIPPED_BIT)
Examples
thermoplastic.cpp.

Definition at line 272 of file thermoplastic.cpp.

◆ flux_order

int flux_order = order

Order of tau field.

Examples
thermoplastic.cpp.

Definition at line 241 of file thermoplastic.cpp.

◆ Gaussian_distribution

auto Gaussian_distribution
Initial value:
= [](double init_temp, double peak_temp, double x,
double y, double z) {
double s =
std::sqrt(-2. * std::log(0.01 * peak_temp / (peak_temp - init_temp)));
return (peak_temp - init_temp) * exp(-pow(y, 2) / (2. * pow(s, 2))) +
}
double peak_temp
double init_temp
double width
Width of Gaussian distribution.
Examples
thermoplastic.cpp.

Definition at line 278 of file thermoplastic.cpp.

279 {
280 double s =
281 width /
282 std::sqrt(-2. * std::log(0.01 * peak_temp / (peak_temp - init_temp)));
283 return (peak_temp - init_temp) * exp(-pow(y, 2) / (2. * pow(s, 2))) +
284 init_temp;
285};

◆ geom_order

int geom_order = 2

Order if fixed.

Examples
thermoplastic.cpp.

Definition at line 243 of file thermoplastic.cpp.

◆ get_string_from_vector

auto get_string_from_vector
Initial value:
= [](auto vec) {
std::string output_string = "";
for (auto el : vec) {
output_string += std::to_string(el) + " ";
}
return output_string;
}
Examples
thermoplastic.cpp.

Definition at line 571 of file thermoplastic.cpp.

571 {
572 std::string output_string = "";
573 for (auto el : vec) {
574 output_string += std::to_string(el) + " ";
575 }
576 return output_string;
577};

◆ H

double H = 584.3

Hardening.

Examples
thermoplastic.cpp.

Definition at line 206 of file thermoplastic.cpp.

◆ heat_capacity_scaling

ScalerFunTwoArgs heat_capacity_scaling

◆ help

char help[] = "...\n\n"
static

[Solve]

Definition at line 5661 of file thermoplastic.cpp.

◆ ic_type

ICType ic_type = IC_UNIFORM
Examples
thermoplastic.cpp.

Definition at line 221 of file thermoplastic.cpp.

◆ ICTypes

const char* const ICTypes[]
Initial value:
= {"uniform", "gaussian", "linear",
"ICType", "IC_", nullptr}
Examples
thermoplastic.cpp.

Definition at line 218 of file thermoplastic.cpp.

218 {"uniform", "gaussian", "linear",
219 "ICType", "IC_", nullptr};

◆ inelastic_heat_fraction

double inelastic_heat_fraction
Initial value:
=
0.9

fraction of plastic dissipation converted to heat

Examples
thermoplastic.cpp.

Definition at line 234 of file thermoplastic.cpp.

◆ inelastic_heat_fraction_scaling

ScalerFunThreeArgs inelastic_heat_fraction_scaling
Examples
ThermoPlasticOps.hpp, and thermoplastic.cpp.

Definition at line 201 of file thermoplastic.cpp.

◆ init_dt

double init_dt = 0.05
Examples
thermoplastic.cpp.

Definition at line 254 of file thermoplastic.cpp.

◆ init_T

auto init_T
Initial value:
= [](double init_temp, double peak_temp, double x, double y,
double z) {
switch (ic_type) {
case IC_LINEAR:
case IC_UNIFORM:
default:
}
}
ICType ic_type
auto linear_distribution
auto uniform_distribution
auto Gaussian_distribution

Initialisation function for temperature field.

Examples
EdgeFlippingOps.hpp, ThermoElasticOps.hpp, and thermoplastic.cpp.

Definition at line 298 of file thermoplastic.cpp.

299 {
300 switch (ic_type) {
301 case IC_GAUSSIAN:
302 return -Gaussian_distribution(init_temp, peak_temp, x, y, z);
303 case IC_LINEAR:
304 return -linear_distribution(init_temp, peak_temp, x, y, z);
305 case IC_UNIFORM:
306 default:
307 return -uniform_distribution(init_temp, peak_temp, x, y, z);
308 }
309};

◆ init_temp

double init_temp = 20.0
Examples
thermoplastic.cpp.

Definition at line 222 of file thermoplastic.cpp.

◆ is_distributed_mesh

PetscBool is_distributed_mesh = PETSC_TRUE
Examples
SolutionMapping.hpp, and thermoplastic.cpp.

Definition at line 194 of file thermoplastic.cpp.

◆ IS_LARGE_STRAINS

constexpr bool IS_LARGE_STRAINS
constexpr
Initial value:
=
#define FINITE_DEFORMATION_FLAG

Definition at line 52 of file thermoplastic.cpp.

◆ is_large_strains

const bool is_large_strains
Initial value:
=
constexpr bool IS_LARGE_STRAINS

Definition at line 186 of file thermoplastic.cpp.

◆ is_quasi_static

PetscBool is_quasi_static = PETSC_TRUE

Definition at line 251 of file thermoplastic.cpp.

◆ IT

constexpr IntegrationType IT
constexpr
Initial value:
=
IntegrationType::GAUSS
Examples
thermoplastic.cpp.

Definition at line 58 of file thermoplastic.cpp.

◆ linear_distribution

auto linear_distribution
Initial value:
= [](double init_temp, double peak_temp, double x,
double y, double z) {
return ((peak_temp - init_temp) / width) * y + (peak_temp + init_temp) / 2.0;
}
Examples
thermoplastic.cpp.

Definition at line 287 of file thermoplastic.cpp.

288 {
289 return ((peak_temp - init_temp) / width) * y + (peak_temp + init_temp) / 2.0;
290};

◆ min_dt

double min_dt = 1e-12
Examples
thermoplastic.cpp.

Definition at line 255 of file thermoplastic.cpp.

◆ num_refinement_levels

int num_refinement_levels = 1
Examples
SolutionMapping.hpp, and thermoplastic.cpp.

Definition at line 259 of file thermoplastic.cpp.

◆ omega_0

double omega_0 = 2e-3

flow stress softening

Examples
thermoplastic.cpp.

Definition at line 232 of file thermoplastic.cpp.

◆ omega_h

double omega_h = 2e-3

hardening softening

Examples
thermoplastic.cpp.

Definition at line 233 of file thermoplastic.cpp.

◆ order

int order = 2

Order displacement.

Definition at line 238 of file thermoplastic.cpp.

◆ order_edge

PetscBool order_edge = PETSC_FALSE

◆ order_face

PetscBool order_face = PETSC_FALSE

◆ order_volume

PetscBool order_volume = PETSC_FALSE

◆ peak_temp

double peak_temp = 1000.0
Examples
thermoplastic.cpp.

Definition at line 223 of file thermoplastic.cpp.

◆ poisson_ratio

double poisson_ratio = 0.31

Poisson ratio.

Definition at line 204 of file thermoplastic.cpp.

◆ post_processing_counter

int post_processing_counter = 0
Examples
thermoplastic.cpp.

Definition at line 349 of file thermoplastic.cpp.

◆ prev_mesh_bit

BitRefLevel prev_mesh_bit = BitRefLevel().set(PREVIOUS_BIT)
Examples
thermoplastic.cpp.

Definition at line 274 of file thermoplastic.cpp.

◆ Qinf

double Qinf = 174.2

Saturation yield stress.

Definition at line 209 of file thermoplastic.cpp.

◆ qual_thresh

double qual_thresh = 0.1
Examples
thermoplastic.cpp.

Definition at line 257 of file thermoplastic.cpp.

◆ qual_tol

double qual_tol = 0
Examples
thermoplastic.cpp.

Definition at line 256 of file thermoplastic.cpp.

◆ refined_bit

BitRefLevel refined_bit = BitRefLevel().set(FIRST_REF_BIT)
Examples
thermoplastic.cpp.

Definition at line 273 of file thermoplastic.cpp.

◆ restart_file

char restart_file[255]

◆ restart_flg

PetscBool restart_flg = PETSC_TRUE

◆ restart_step

int restart_step = 0
Examples
PlasticOpsMonitor.hpp, and thermoplastic.cpp.

Definition at line 193 of file thermoplastic.cpp.

◆ restart_time

double restart_time = 0
Examples
thermoplastic.cpp.

Definition at line 192 of file thermoplastic.cpp.

◆ rho

double rho = 0.0

Definition at line 252 of file thermoplastic.cpp.

◆ save_range

auto save_range
Initial value:
= [](moab::Interface &moab, const std::string name,
const Range r) {
auto out_meshset = get_temp_meshset_ptr(moab);
CHKERR moab.add_entities(*out_meshset, r);
CHKERR moab.write_file(name.c_str(), "VTK", "", out_meshset->get_ptr(), 1);
}
auto get_temp_meshset_ptr(moab::Interface &moab)
Create smart pointer to temporary meshset.
Examples
thermoplastic.cpp.

Definition at line 562 of file thermoplastic.cpp.

563 {
565 auto out_meshset = get_temp_meshset_ptr(moab);
566 CHKERR moab.add_entities(*out_meshset, r);
567 CHKERR moab.write_file(name.c_str(), "VTK", "", out_meshset->get_ptr(), 1);
569};

◆ scale

double scale = 1.
Examples
thermoplastic.cpp.

Definition at line 196 of file thermoplastic.cpp.

◆ set_timer

PetscBool set_timer = PETSC_FALSE

Set timer.

Definition at line 188 of file thermoplastic.cpp.

◆ sigmaY

double sigmaY = 936.2

Yield stress.

Definition at line 205 of file thermoplastic.cpp.

◆ size_symm

constexpr auto size_symm = (SPACE_DIM * (SPACE_DIM + 1)) / 2
constexpr

Definition at line 50 of file thermoplastic.cpp.

◆ SPACE_DIM

constexpr int SPACE_DIM
constexpr
Initial value:
=
3
Examples
thermoplastic.cpp.

Definition at line 48 of file thermoplastic.cpp.

◆ storage_bit

BitRefLevel storage_bit = BitRefLevel().set(STORAGE_BIT)
Examples
thermoplastic.cpp.

Definition at line 276 of file thermoplastic.cpp.

◆ T_order

int T_order = order - 1

Order of ep field.

Examples
thermoplastic.cpp.

Definition at line 242 of file thermoplastic.cpp.

◆ tau_order

int tau_order = order - 2

Order of tau field.

Definition at line 239 of file thermoplastic.cpp.

◆ temp_0

double temp_0 = 20

reference temperature for thermal softening

Examples
thermoplastic.cpp.

Definition at line 236 of file thermoplastic.cpp.

◆ thermal_conductivity_scaling

ScalerFunTwoArgs thermal_conductivity_scaling

◆ thermoplastic_raw_ptr

Example* thermoplastic_raw_ptr = nullptr
Examples
thermoplastic.cpp.

Definition at line 4394 of file thermoplastic.cpp.

◆ ts_to_ctx

std::unordered_map<TS, MyTsCtx *> ts_to_ctx
static
Examples
thermoplastic.cpp.

Definition at line 4124 of file thermoplastic.cpp.

◆ ts_to_rctx

std::unordered_map<TS, ResizeCtx *> ts_to_rctx
static
Examples
thermoplastic.cpp.

Definition at line 641 of file thermoplastic.cpp.

◆ tsPrePostProc

boost::weak_ptr<TSPrePostProc> tsPrePostProc
static

◆ uniform_distribution

auto uniform_distribution
Initial value:
= [](double init_temp, double peak_temp, double x,
double y, double z) { return init_temp; }
Examples
thermoplastic.cpp.

Definition at line 292 of file thermoplastic.cpp.

293 { return init_temp; };

◆ virgin_mesh_bit

BitRefLevel virgin_mesh_bit = BitRefLevel().set(VIRGIN_BIT)
Examples
thermoplastic.cpp.

Definition at line 275 of file thermoplastic.cpp.

◆ visH

double visH = 0

Viscous hardening.

Definition at line 207 of file thermoplastic.cpp.

◆ width

double width = 10.0

Width of Gaussian distribution.

Examples
thermoplastic.cpp.

Definition at line 224 of file thermoplastic.cpp.

◆ young_modulus

double young_modulus = 115000

Young modulus.

Definition at line 203 of file thermoplastic.cpp.

◆ zeta

double zeta = 5e-2

regularisation parameter

Definition at line 208 of file thermoplastic.cpp.