v0.16.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 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 = 10*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 = 0
 
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 71 of file thermoplastic.cpp.

◆ BoundaryEle

Definition at line 64 of file thermoplastic.cpp.

◆ BoundaryEleOp

Definition at line 65 of file thermoplastic.cpp.

◆ BoundaryLhsBCs

Definition at line 590 of file thermoplastic.cpp.

◆ BoundaryNaturalBC

[Body and heat source]

[Natural boundary conditions]

Definition at line 605 of file thermoplastic.cpp.

◆ BoundaryRhsBCs

Definition at line 587 of file thermoplastic.cpp.

◆ DomainEle

Definition at line 62 of file thermoplastic.cpp.

◆ DomainEleOp

Definition at line 63 of file thermoplastic.cpp.

◆ DomainNaturalBCLhs

Definition at line 600 of file thermoplastic.cpp.

◆ DomainNaturalBCRhs

[Body and heat source]

Definition at line 595 of file thermoplastic.cpp.

◆ DomainRhsBCs

Definition at line 584 of file thermoplastic.cpp.

◆ EntData

Definition at line 61 of file thermoplastic.cpp.

◆ OpBodyForce

Definition at line 596 of file thermoplastic.cpp.

◆ OpBoundaryLhsBCs

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

Definition at line 591 of file thermoplastic.cpp.

◆ OpBoundaryRhsBCs

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

Definition at line 588 of file thermoplastic.cpp.

◆ OpDomainRhsBCs

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

Definition at line 585 of file thermoplastic.cpp.

◆ OpEssentialFluxLhs

Definition at line 615 of file thermoplastic.cpp.

◆ OpEssentialFluxRhs

[Natural boundary conditions]

[Essential boundary conditions (Least square approach)]

Definition at line 613 of file thermoplastic.cpp.

◆ OpForce

Definition at line 607 of file thermoplastic.cpp.

◆ OpHeatSource

Definition at line 598 of file thermoplastic.cpp.

◆ OpSetTemperatureLhs

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

Definition at line 621 of file thermoplastic.cpp.

◆ OpSetTemperatureRhs

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

[Essential boundary conditions (Least square approach)]

Definition at line 619 of file thermoplastic.cpp.

◆ OpTemperatureBC

Definition at line 608 of file thermoplastic.cpp.

◆ PostProcEle

Definition at line 66 of file thermoplastic.cpp.

◆ ScalerFunThreeArgs

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

Definition at line 74 of file thermoplastic.cpp.

◆ ScalerFunTwoArgs

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

Definition at line 73 of file thermoplastic.cpp.

◆ SetPtsData

Definition at line 69 of file thermoplastic.cpp.

◆ SideEle

Definition at line 68 of file thermoplastic.cpp.

◆ SkinPostProcEle

Definition at line 67 of file thermoplastic.cpp.

Enumeration Type Documentation

◆ ICType

enum ICType
Enumerator
IC_UNIFORM 
IC_GAUSSIAN 
IC_LINEAR 

Definition at line 279 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 323 of file thermoplastic.cpp.

323 {
324 COMPUTATION_BIT = 0,
325 FLIPPED_BIT = 1,
326 FIRST_REF_BIT = 2,
331};
#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 148 of file thermoplastic.cpp.

148 {
149 return -H * omega_h;
150}
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 166 of file thermoplastic.cpp.

166 {
167 return -Qinf * omega_h;
168}
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 157 of file thermoplastic.cpp.

157 {
158 return -sigmaY * omega_0;
159}
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 184 of file thermoplastic.cpp.

184 {
185 return std::exp(exp_C * pow(temp_hat, 2) + exp_D * temp_hat);
186}
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 144 of file thermoplastic.cpp.

144 {
145 return H * (1. - omega_h * (temp - temp_0));
146}
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 191 of file thermoplastic.cpp.

193 {
194 return (sigmaY + H * tau + Qinf * (1. - iso_hardening_exp(tau, b_iso))) *
196}
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 198 of file thermoplastic.cpp.

200 {
201 return (H + Qinf * b_iso * iso_hardening_exp(tau, b_iso)) *
203}

◆ 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 205 of file thermoplastic.cpp.

207 {
208 double JC_ref_temp = 0.;
209 double JC_melt_temp = 1650.;
210 double T_hat = temp_hat(temp);
211
212 return (sigmaY + H * tau + Qinf * (1. - iso_hardening_exp(tau, b_iso))) *
213 (exp_D + 2 * T_hat * exp_C) *
214 std::exp(exp_D * T_hat + pow(T_hat, 2) * exp_C) /
215 (JC_melt_temp - JC_ref_temp);
216}

◆ iso_hardening_exp()

double iso_hardening_exp ( double  tau,
double  b_iso 
)
inline

Definition at line 170 of file thermoplastic.cpp.

170 {
171 return std::exp(-b_iso * tau);
172}

◆ 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 223 of file thermoplastic.cpp.

224 {
225 FTensor::Index<'i', DIM> i;
226 FTensor::Index<'j', DIM> j;
228 if (C1_k < std::numeric_limits<double>::epsilon()) {
229 t_alpha(i, j) = 0;
230 return t_alpha;
231 }
232 t_alpha(i, j) = C1_k * t_plastic_strain(i, j);
233 return t_alpha;
234}
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 237 of file thermoplastic.cpp.

237 {
238 FTensor::Index<'i', DIM> i;
239 FTensor::Index<'j', DIM> j;
240 FTensor::Index<'k', DIM> k;
241 FTensor::Index<'l', DIM> l;
244 t_diff(i, j, k, l) = C1_k * (t_kd(i, k) ^ t_kd(j, l)) / 4.;
245 return t_diff;
246}
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 5743 of file thermoplastic.cpp.

5743 {
5744
5745#ifdef ADD_CONTACT
5746 #ifdef ENABLE_PYTHON_BINDING
5747 Py_Initialize();
5748 np::initialize();
5749 #endif
5750#endif // ADD_CONTACT
5751
5752 // Initialisation of MoFEM/PETSc and MOAB data structures
5753 const char param_file[] = "param_file.petsc";
5754 MoFEM::Core::Initialize(&argc, &argv, param_file, help);
5755
5756 // Add logging channel for example
5757 auto core_log = logging::core::get();
5758 core_log->add_sink(
5760 core_log->add_sink(
5762 core_log->add_sink(
5763 LogManager::createSink(LogManager::getStrmWorld(), "THERMOPLASTICITY"));
5764 core_log->add_sink(
5766 core_log->add_sink(
5768 LogManager::setLog("PLASTICITY");
5769 LogManager::setLog("THERMAL");
5770 LogManager::setLog("THERMOPLASTICITY");
5771 LogManager::setLog("REMESHING");
5772 MOFEM_LOG_TAG("PLASTICITY", "Plasticity");
5773 MOFEM_LOG_TAG("THERMAL", "Thermal");
5774 MOFEM_LOG_TAG("THERMOPLASTICITY", "Thermoplasticity");
5775 MOFEM_LOG_TAG("REMESHING", "Remeshing");
5776
5777#ifdef ADD_CONTACT
5778 core_log->add_sink(
5780 LogManager::setLog("CONTACT");
5781 MOFEM_LOG_TAG("CONTACT", "Contact");
5782#endif // ADD_CONTACT
5783
5784 try {
5785
5786 //! [Register MoFEM discrete manager in PETSc]
5787 DMType dm_name = "DMMOFEM";
5788 CHKERR DMRegister_MoFEM(dm_name);
5789 //! [Register MoFEM discrete manager in PETSc
5790
5791 //! [Create MoAB]
5792 moab::Core mb_instance; ///< mesh database
5793 moab::Interface &moab = mb_instance; ///< mesh database interface
5794 //! [Create MoAB]
5795
5796 //! [Create MoFEM]
5797 MoFEM::Core core(moab); ///< finite element database
5798 MoFEM::Interface &m_field = core; ///< finite element database interface
5799 //! [Create MoFEM]
5800
5801 //! [Load mesh]
5802 Simple *simple = m_field.getInterface<Simple>();
5804
5805 simple->getBitRefLevel() = comp_mesh_bit;
5806 simple->getBitRefLevelMask() = BitRefLevel().set();
5807
5808 CHKERR PetscOptionsGetBool(PETSC_NULLPTR, "", "-is_distributed_mesh",
5809 &is_distributed_mesh, PETSC_NULLPTR);
5810 if (is_distributed_mesh == PETSC_TRUE) {
5811 CHKERR simple->loadFile();
5812 } else {
5813 char meshFileName[255];
5814 CHKERR PetscOptionsGetString(PETSC_NULLPTR, PETSC_NULLPTR, "-file_name",
5815 meshFileName, 255, PETSC_NULLPTR);
5816 CHKERR simple->loadFile("", meshFileName);
5817 }
5818
5819 Range ents;
5820 CHKERR m_field.get_moab().get_entities_by_dimension(0, SPACE_DIM, ents,
5821 true);
5822 CHKERR m_field.getInterface<BitRefManager>()->setBitRefLevel(
5824 false);
5825 //! [Load mesh]
5826
5827 //! [Example]
5828 Example ex(m_field);
5829 CHKERR ex.runProblem();
5830 //! [Example]
5831 }
5833
5835
5836#ifdef ADD_CONTACT
5837 #ifdef ENABLE_PYTHON_BINDING
5838 if (Py_FinalizeEx() < 0) {
5839 exit(120);
5840 }
5841 #endif
5842#endif // ADD_CONTACT
5843
5844 return 0;
5845}
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:217
Managing BitRefLevels.
virtual moab::Interface & get_moab()=0
Core (interface) class.
Definition Core.hpp:83
static MoFEMErrorCode Initialize(int *argc, char ***args, const char file[], const char help[])
Initializes the MoFEM database PETSc, MOAB and MPI.
Definition Core.cpp:68
static MoFEMErrorCode Finalize()
Checks for options to be called at the conclusion of the program.
Definition Core.cpp:123
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 4216 of file thermoplastic.cpp.

4217 {
4218 PetscFunctionBegin;
4219 ResizeCtx *rctx = static_cast<ResizeCtx *>(ctx);
4220 *resize = rctx->mesh_changed;
4221 PetscFunctionReturn(0);
4222}
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 4224 of file thermoplastic.cpp.

4225 {
4226 PetscFunctionBegin;
4227 ResizeCtx *rctx = static_cast<ResizeCtx *>(ctx);
4228
4229 if (auto ptr = rctx->ptr.lock()) {
4230
4231 MoFEM::Interface &m_field = *(rctx->m_field);
4232
4233 auto bit_mng = m_field.getInterface<BitRefManager>();
4234
4235 auto set_prev_mesh_bit = [](EntityHandle ent, BitRefLevel &bit) {
4236 if (bit[COMPUTATION_BIT]) {
4237 bit.set(COMPUTATION_BIT, false);
4238 bit.set(PREVIOUS_BIT, true);
4239 }
4240 };
4241
4242 CHKERR bit_mng->lambdaBitRefLevel(set_prev_mesh_bit);
4243
4244 std::string improved_reasons = "";
4245
4246 Range edges_to_not_refine;
4247
4248 CHKERR ptr->ExRawPtr->doEdgeFlips(rctx->el_q_map, rctx->flipped_els,
4249 rctx->th_spatial_coords,
4250 rctx->new_connectivity);
4251 if (rctx->el_q_map.size() > 0) {
4252 improved_reasons += ", Edge flipping";
4253 }
4254
4255 bool refined = false;
4256 int step;
4257 CHKERR TSGetStepNumber(ts, &step);
4258 CHKERR ptr->ExRawPtr->doEdgeSplits(refined, (step) ? true : false);
4259 if (refined) {
4260 improved_reasons += ", Edge splitting";
4261 }
4262
4263 // Erase leading ", " from improved_reasons
4264 improved_reasons.erase(0, 2);
4265
4266 if (improved_reasons != "")
4267 MOFEM_LOG("REMESHING", Sev::inform)
4268 << "Improved mesh quality by: " << improved_reasons;
4269
4270#ifndef NDEBUG
4271
4272 // comp_mesh_bit = BitRefLevel().set(COMPUTATION_BIT);
4273 // flipped_bit = BitRefLevel().set(FLIPPED_BIT);
4274 // refined_bit = BitRefLevel().set(FIRST_REF_BIT);
4275 // prev_mesh_bit = BitRefLevel().set(PREVIOUS_BIT);
4276 // virgin_mesh_bit = BitRefLevel().set(VIRGIN_BIT);
4277 // storage_bit = BitRefLevel().set(STORAGE_BIT);
4278
4279 if (m_field.get_comm_rank() == 0) {
4280 CHKERR m_field.getInterface<BitRefManager>()->writeBitLevelByDim(
4281 comp_mesh_bit, BitRefLevel().set(), 2,
4282 "before_mapping_comp_mesh_bit.vtk", "VTK", "");
4283 CHKERR m_field.getInterface<BitRefManager>()->writeBitLevelByDim(
4284 flipped_bit, BitRefLevel().set(), 2, "before_mapping_flipped_bit.vtk",
4285 "VTK", "");
4286 CHKERR m_field.getInterface<BitRefManager>()->writeBitLevelByDim(
4287 refined_bit, BitRefLevel().set(), 2, "before_mapping_refined_bit.vtk",
4288 "VTK", "");
4289 CHKERR m_field.getInterface<BitRefManager>()->writeBitLevelByDim(
4290 prev_mesh_bit, BitRefLevel().set(), 2,
4291 "before_mapping_prev_mesh_bit.vtk", "VTK", "");
4292 CHKERR m_field.getInterface<BitRefManager>()->writeBitLevelByDim(
4293 virgin_mesh_bit, BitRefLevel().set(), 2,
4294 "before_mapping_virgin_mesh_bit.vtk", "VTK", "");
4295 }
4296#endif // NDEBUG
4297
4298 MOFEM_LOG("REMESHING", Sev::verbose) << "number of vectors to map = " << nv;
4299
4300 for (PetscInt i = 0; i < nv; ++i) {
4301 double nrm;
4302 CHKERR VecNorm(ts_vecsin[i], NORM_2, &nrm);
4303 MOFEM_LOG("REMESHING", Sev::warning)
4304 << "Before remeshing: ts_vecsin[" << i << "] norm = " << nrm;
4305 }
4306
4307 auto scatter_mng = m_field.getInterface<VecManager>();
4308 auto simple = m_field.getInterface<Simple>();
4309
4310 // CHKERR m_field.getInterface<BitRefManager>()->writeBitLevel(
4311 // BitRefLevel().set(1), BitRefLevel().set(), "before_resettingup.vtk",
4312 // "VTK", "");
4313
4314 // Rebuilding DM with old and new mesh entities
4315 auto bit = BitRefLevel().set();
4317 {"TAU", "EP", "T"}, {tau_order, ep_order, T_order}, {"U"},
4318 {order}, {"FLUX"}, {flux_order}, bit);
4319
4320 // CHKERR m_field.getInterface<BitRefManager>()->writeBitLevel(
4321 // BitRefLevel().set(1), BitRefLevel().set(), "after_resettingup.vtk",
4322 // "VTK", "");
4323
4324 auto intermediate_dm = createDM(m_field.get_comm(), "DMMOFEM");
4326 intermediate_dm, &m_field, "INTERMEDIATE_DM",
4328 BitRefLevel().set());
4329 CHKERR DMMoFEMSetDestroyProblem(intermediate_dm, PETSC_TRUE);
4330 CHKERR DMSetFromOptions(intermediate_dm);
4331 CHKERR DMMoFEMAddElement(intermediate_dm, simple->getDomainFEName());
4332 CHKERR DMMoFEMSetSquareProblem(intermediate_dm, PETSC_TRUE);
4334 CHKERR DMSetUp(intermediate_dm);
4335
4336 Vec vec_in[nv], vec_out[nv];
4337 for (PetscInt i = 0; i < nv; ++i) {
4338 CHKERR DMCreateGlobalVector(intermediate_dm, &vec_in[i]);
4339 CHKERR VecDuplicate(vec_in[i], &vec_out[i]);
4340 }
4341
4342 VecScatter scatter_to_intermediate;
4343
4344 for (PetscInt i = 0; i < nv; ++i) {
4345 CHKERR scatter_mng->vecScatterCreate(
4346 ts_vecsin[i], simple->getProblemName(), RowColData::ROW, vec_in[i],
4347 "INTERMEDIATE_DM", RowColData::ROW, &scatter_to_intermediate);
4348 CHKERR VecScatterBegin(scatter_to_intermediate, ts_vecsin[i], vec_in[i],
4349 INSERT_VALUES, SCATTER_FORWARD);
4350 CHKERR VecScatterEnd(scatter_to_intermediate, ts_vecsin[i], vec_in[i],
4351 INSERT_VALUES, SCATTER_FORWARD);
4352 }
4353
4354 CHKERR VecScatterDestroy(&scatter_to_intermediate);
4355
4357 intermediate_dm, prev_mesh_bit,
4358 BitRefLevel().set(FLIPPED_BIT + num_refinement_levels), nv, vec_in,
4359 vec_out);
4360
4361 // Build problem on new bit ref level
4362 auto ts_problem_name = simple->getProblemName();
4364 ts_problem_name,
4366 CHKERR m_field.modify_problem_mask_ref_level_set_bit(ts_problem_name,
4367 BitRefLevel().set());
4369 PetscBarrier(nullptr);
4370 CHKERR DMSetUp_MoFEM(simple->getDM());
4371
4372 // Update meshsets for correct BCs
4373 MeshsetsManager *meshsets_manager_ptr;
4374 CHKERR m_field.getInterface(meshsets_manager_ptr);
4375 CHKERR meshsets_manager_ptr->updateAllMeshsetsByEntitiesChildren(
4376 BitRefLevel().set());
4377
4378 CHKERR ptr->ExRawPtr->mechanicalBC(
4380 BitRefLevel().set());
4381 CHKERR ptr->ExRawPtr->thermalBC(
4383 BitRefLevel().set());
4384
4385 VecScatter scatter_to_final;
4386
4387 for (PetscInt i = 0; i < nv; ++i) {
4388 CHKERR DMCreateGlobalVector(simple->getDM(), &ts_vecsout[i]);
4389 CHKERR scatter_mng->vecScatterCreate(
4390 ts_vecsout[i], simple->getProblemName(), RowColData::ROW, vec_out[i],
4391 "INTERMEDIATE_DM", RowColData::ROW, &scatter_to_final);
4392 CHKERR VecScatterBegin(scatter_to_final, vec_out[i], ts_vecsout[i],
4393 INSERT_VALUES, SCATTER_REVERSE);
4394 CHKERR VecScatterEnd(scatter_to_final, vec_out[i], ts_vecsout[i],
4395 INSERT_VALUES, SCATTER_REVERSE);
4396 CHKERR VecScatterDestroy(&scatter_to_final);
4397 }
4398
4399 for (PetscInt i = 0; i < nv; ++i) {
4400 CHKERR VecDestroy(&vec_in[i]);
4401 CHKERR VecDestroy(&vec_out[i]);
4402 }
4403
4404 auto set_all_bit = [&](EntityHandle ent, BitRefLevel &bit) {
4405 for (auto l = 0; l <= FLIPPED_BIT + num_refinement_levels; ++l) {
4406 bit.set(STORAGE_BIT, true);
4407 }
4408 if (bit[VIRGIN_BIT]) {
4409 bit.set(VIRGIN_BIT, false);
4410 }
4411 if (bit[FLIPPED_BIT]) {
4412 bit.set(VIRGIN_BIT, true);
4413 }
4414 if (bit[PREVIOUS_BIT]) {
4415 bit.set(PREVIOUS_BIT, false);
4416 }
4418 bit.set(COMPUTATION_BIT, true);
4419 }
4420 };
4421 CHKERR bit_mng->lambdaBitRefLevel(set_all_bit);
4422
4423#ifndef NDEBUG
4424
4425 // comp_mesh_bit = BitRefLevel().set(COMPUTATION_BIT);
4426 // flipped_bit = BitRefLevel().set(FLIPPED_BIT);
4427 // refined_bit = BitRefLevel().set(FIRST_REF_BIT);
4428 // prev_mesh_bit = BitRefLevel().set(PREVIOUS_BIT);
4429 // virgin_mesh_bit = BitRefLevel().set(VIRGIN_BIT);
4430 // storage_bit = BitRefLevel().set(STORAGE_BIT);
4431
4432 if (m_field.get_comm_rank() == 0) {
4433 CHKERR m_field.getInterface<BitRefManager>()->writeBitLevelByDim(
4434 comp_mesh_bit, BitRefLevel().set(), 2,
4435 "after_mapping_comp_mesh_bit.vtk", "VTK", "");
4436 CHKERR m_field.getInterface<BitRefManager>()->writeBitLevelByDim(
4437 flipped_bit, BitRefLevel().set(), 2, "after_mapping_flipped_bit.vtk",
4438 "VTK", "");
4439 CHKERR m_field.getInterface<BitRefManager>()->writeBitLevelByDim(
4440 refined_bit, BitRefLevel().set(), 2, "after_mapping_refined_bit.vtk",
4441 "VTK", "");
4442 CHKERR m_field.getInterface<BitRefManager>()->writeBitLevelByDim(
4443 prev_mesh_bit, BitRefLevel().set(), 2,
4444 "after_mapping_prev_mesh_bit.vtk", "VTK", "");
4445 CHKERR m_field.getInterface<BitRefManager>()->writeBitLevelByDim(
4446 virgin_mesh_bit, BitRefLevel().set(), 2,
4447 "after_mapping_virgin_mesh_bit.vtk", "VTK", "");
4448 }
4449#endif // NDEBUG
4450
4451 CHKERR m_field.modify_problem_ref_level_set_bit(ts_problem_name,
4453 CHKERR m_field.modify_problem_mask_ref_level_set_bit(ts_problem_name,
4454 BitRefLevel().set());
4455
4456 CHKERR TSSetDM(ts, simple->getDM());
4457
4458 auto B = createDMMatrix(simple->getDM());
4459 CHKERR TSSetIJacobian(ts, B, B, nullptr, nullptr);
4460 }
4461
4462 for (PetscInt i = 0; i < nv; ++i) {
4463 double nrm;
4464 CHKERR VecNorm(ts_vecsout[i], NORM_2, &nrm);
4465 MOFEM_LOG("REMESHING", Sev::warning)
4466 << "After remeshing: ts_vecsout[" << i << "] norm = " << nrm;
4467 }
4468
4469 PetscFunctionReturn(0);
4470}
@ 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:1194
PetscErrorCode DMSetUp_MoFEM(DM dm)
Definition DMMoFEM.cpp:1298
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 413 of file thermoplastic.cpp.

414 {
416
417 auto create_post_process_elements = [&]() {
419 auto pp_fe = boost::make_shared<PostProcEle>(m_field);
420
421 auto push_vol_post_proc_ops = [&](auto &pp_fe) {
423
424 auto &pip = pp_fe->getOpPtrVector();
425
426 auto TAU_ptr = boost::make_shared<VectorDouble>();
427 pip.push_back(new OpCalculateScalarFieldValues("TAU", TAU_ptr));
428 auto T_ptr = boost::make_shared<VectorDouble>();
429 pip.push_back(new OpCalculateScalarFieldValues("T", T_ptr));
430
431 auto T_grad_ptr = boost::make_shared<MatrixDouble>();
432 pip.push_back(
433 new OpCalculateScalarFieldGradient<SPACE_DIM>("T", T_grad_ptr));
434 auto U_ptr = boost::make_shared<MatrixDouble>();
435 pip.push_back(new OpCalculateVectorFieldValues<SPACE_DIM>("U", U_ptr));
436 auto FLUX_ptr = boost::make_shared<MatrixDouble>();
437 pip.push_back(
438 new OpCalculateHVecVectorField<3, SPACE_DIM>("FLUX", FLUX_ptr));
439
440 auto EP_ptr = boost::make_shared<MatrixDouble>();
441 pip.push_back(
443
445
446 pip.push_back(
447
448 new OpPPMap(
449
450 pp_fe->getPostProcMesh(), pp_fe->getMapGaussPts(),
451
452 {{"TAU", TAU_ptr}, {"T", T_ptr}},
453
454 {{"U", U_ptr}, {"FLUX", FLUX_ptr}, {"T_GRAD", T_grad_ptr}},
455
456 {},
457
458 {{"EP", EP_ptr}}
459
460 )
461
462 );
463
465 };
466
467 CHKERR push_vol_post_proc_ops(pp_fe);
468
469 if (m_field.get_comm_size() == 1) {
470
471 CHKERR DMoFEMLoopFiniteElements(dm, "dFE", pp_fe);
472 CHKERR pp_fe->writeFile("out_" + std::to_string(counter) + "_" +
473 output_name + ".h5m");
474 } else {
475
477 m_field.get_comm_size());
478 auto &post_proc_moab = pp_fe->getPostProcMesh();
479 auto file_name = "out_" + std::to_string(counter) + "_" + output_name +
480 "_" + std::to_string(m_field.get_comm_rank()) + ".vtk";
481 MOFEM_LOG("WORLD", Sev::inform)
482 << "Writing file " << file_name << std::endl;
483 CHKERR post_proc_moab.write_file(file_name.c_str(), "VTK");
484 }
485 counter++;
486
488 };
489
490 CHKERR create_post_process_elements();
491
493}
#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 MatrixDouble 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 495 of file thermoplastic.cpp.

496 {
498
499 auto smart_sol = SmartPetscObj<Vec>(sol, true);
500
501 auto create_post_process_elements = [&]() {
503 auto pp_fe = boost::make_shared<PostProcEle>(m_field);
504
505 auto push_vol_post_proc_ops = [&](auto &pp_fe) {
507
508 auto &pip = pp_fe->getOpPtrVector();
509
510 auto TAU_ptr = boost::make_shared<VectorDouble>();
511 pip.push_back(
512 new OpCalculateScalarFieldValues("TAU", TAU_ptr, smart_sol));
513 auto T_ptr = boost::make_shared<VectorDouble>();
514 pip.push_back(new OpCalculateScalarFieldValues("T", T_ptr, smart_sol));
515
516 auto U_ptr = boost::make_shared<MatrixDouble>();
517 pip.push_back(
518 new OpCalculateVectorFieldValues<SPACE_DIM>("U", U_ptr, smart_sol));
519 auto FLUX_ptr = boost::make_shared<MatrixDouble>();
521 "FLUX", FLUX_ptr, smart_sol));
522
523 auto EP_ptr = boost::make_shared<MatrixDouble>();
525 "EP", EP_ptr, smart_sol));
526
528
529 pip.push_back(
530
531 new OpPPMap(
532
533 pp_fe->getPostProcMesh(), pp_fe->getMapGaussPts(),
534
535 {{"TAU", TAU_ptr}, {"T", T_ptr}},
536
537 {{"U", U_ptr}, {"FLUX", FLUX_ptr}},
538
539 {},
540
541 {{"EP", EP_ptr}}
542
543 )
544
545 );
546
548 };
549
550 CHKERR push_vol_post_proc_ops(pp_fe);
551
552 CHKERR DMoFEMLoopFiniteElements(dm, "dFE", pp_fe);
553 CHKERR pp_fe->writeFile("out_" + output_name + ".h5m");
554
556 };
557
558 CHKERR create_post_process_elements();
559
561}
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 563 of file thermoplastic.cpp.

565 {
567 auto rank = m_field.get_comm_rank();
568 auto size = m_field.get_comm_size();
569
570 // Loop through all processes and print one by one
571 for (int i = 0; i < size; ++i) {
572 // If it is this process's turn, print the data
573 if (i == rank) {
574 std::cout << "Proc " << rank << " " + out_put_string + " "
575 << out_put_quantity << std::endl;
576 }
577 // All processes wait here until the current one has finished
578 // printing
579 CHKERR PetscBarrier(NULL);
580 }
582};

◆ Qinf_thermal()

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

Definition at line 161 of file thermoplastic.cpp.

162 {
163 return Qinf * (1. - omega_h * (temp - temp_0));
164}

◆ SNESIterationMonitor()

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

Definition at line 4208 of file thermoplastic.cpp.

4209 {
4211 MyTsCtx *my_ctx = static_cast<MyTsCtx *>(ctx);
4212 my_ctx->snes_iter_counter++;
4214}
PetscInt snes_iter_counter

◆ temp_hat()

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

Definition at line 177 of file thermoplastic.cpp.

177 {
178 double JC_ref_temp = 0.;
179 double JC_melt_temp = 1650.;
180
181 return (temp - JC_ref_temp) / (JC_melt_temp - JC_ref_temp);
182}

◆ TSIterationPreStage()

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

Definition at line 4200 of file thermoplastic.cpp.

4200 {
4202 MyTsCtx *my_ctx = ts_to_ctx[ts];
4203 my_ctx->snes_iter_counter = 0;
4205}
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 152 of file thermoplastic.cpp.

153 {
154 return sigmaY * (1. - omega_0 * (temp - temp_0));
155}

Variable Documentation

◆ alpha_damping

double alpha_damping = 0

Definition at line 315 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 51 of file thermoplastic.cpp.

◆ atom_test

int atom_test = 0

Definition at line 307 of file thermoplastic.cpp.

◆ b_iso

double b_iso = 63.69

Saturation exponent.

Definition at line 272 of file thermoplastic.cpp.

◆ C1_k

double C1_k = 0

Kinematic hardening.

Definition at line 273 of file thermoplastic.cpp.

◆ cn0

double cn0 = 1

Definition at line 275 of file thermoplastic.cpp.

◆ cn1

double cn1 = 1

Definition at line 276 of file thermoplastic.cpp.

◆ comp_mesh_bit

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

Definition at line 333 of file thermoplastic.cpp.

◆ CONTACT_SPACE

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

Definition at line 59 of file thermoplastic.cpp.

◆ default_coeff_expansion

double default_coeff_expansion = 1e-5

Definition at line 287 of file thermoplastic.cpp.

◆ default_heat_capacity

double default_heat_capacity = 10*2.332

Definition at line 291 of file thermoplastic.cpp.

◆ default_heat_capacity_scale

double default_heat_capacity_scale = 1.
Examples
thermoplastic.cpp.

Definition at line 260 of file thermoplastic.cpp.

◆ default_heat_conductivity

double default_heat_conductivity
Initial value:
=
11.4

Definition at line 288 of file thermoplastic.cpp.

◆ default_ref_temp

double default_ref_temp = 20.0

Definition at line 278 of file thermoplastic.cpp.

◆ default_thermal_conductivity_scale

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

Definition at line 259 of file thermoplastic.cpp.

◆ do_eval_field

PetscBool do_eval_field = PETSC_FALSE

Evaluate field.

Definition at line 251 of file thermoplastic.cpp.

◆ edge_growth_thresh

double edge_growth_thresh = 0.2
Examples
thermoplastic.cpp.

Definition at line 320 of file thermoplastic.cpp.

◆ ep_order

int ep_order = order - 1

Order of ep field.

Definition at line 302 of file thermoplastic.cpp.

◆ exp_C

double exp_C = -6.284
Examples
thermoplastic.cpp.

Definition at line 174 of file thermoplastic.cpp.

◆ exp_D

double exp_D = -1.024
Examples
thermoplastic.cpp.

Definition at line 175 of file thermoplastic.cpp.

◆ flipped_bit

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

Definition at line 334 of file thermoplastic.cpp.

◆ flux_order

int flux_order = order

Order of tau field.

Examples
thermoplastic.cpp.

Definition at line 303 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 340 of file thermoplastic.cpp.

341 {
342 double s =
343 width /
344 std::sqrt(-2. * std::log(0.01 * peak_temp / (peak_temp - init_temp)));
345 return (peak_temp - init_temp) * exp(-pow(y, 2) / (2. * pow(s, 2))) +
346 init_temp;
347};

◆ geom_order

int geom_order = 2

Order if fixed.

Examples
thermoplastic.cpp.

Definition at line 305 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 633 of file thermoplastic.cpp.

633 {
634 std::string output_string = "";
635 for (auto el : vec) {
636 output_string += std::to_string(el) + " ";
637 }
638 return output_string;
639};

◆ H

double H = 584.3

Hardening.

Examples
thermoplastic.cpp.

Definition at line 268 of file thermoplastic.cpp.

◆ heat_capacity_scaling

ScalerFunTwoArgs heat_capacity_scaling

◆ help

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

[Solve]

Definition at line 5741 of file thermoplastic.cpp.

◆ ic_type

ICType ic_type = IC_UNIFORM
Examples
thermoplastic.cpp.

Definition at line 283 of file thermoplastic.cpp.

◆ ICTypes

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

Definition at line 280 of file thermoplastic.cpp.

280 {"uniform", "gaussian", "linear",
281 "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 296 of file thermoplastic.cpp.

◆ inelastic_heat_fraction_scaling

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

Definition at line 263 of file thermoplastic.cpp.

◆ init_dt

double init_dt = 0.05
Examples
thermoplastic.cpp.

Definition at line 316 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 360 of file thermoplastic.cpp.

361 {
362 switch (ic_type) {
363 case IC_GAUSSIAN:
364 return -Gaussian_distribution(init_temp, peak_temp, x, y, z);
365 case IC_LINEAR:
366 return -linear_distribution(init_temp, peak_temp, x, y, z);
367 case IC_UNIFORM:
368 default:
369 return -uniform_distribution(init_temp, peak_temp, x, y, z);
370 }
371};

◆ init_temp

double init_temp = 20.0
Examples
thermoplastic.cpp.

Definition at line 284 of file thermoplastic.cpp.

◆ is_distributed_mesh

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

Definition at line 256 of file thermoplastic.cpp.

◆ IS_LARGE_STRAINS

constexpr bool IS_LARGE_STRAINS
constexpr
Initial value:
=
#define FINITE_DEFORMATION_FLAG

Definition at line 48 of file thermoplastic.cpp.

◆ is_large_strains

const bool is_large_strains
Initial value:
=
constexpr bool IS_LARGE_STRAINS

Definition at line 248 of file thermoplastic.cpp.

◆ is_quasi_static

PetscBool is_quasi_static = PETSC_TRUE

Definition at line 313 of file thermoplastic.cpp.

◆ IT

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

Definition at line 54 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 349 of file thermoplastic.cpp.

350 {
351 return ((peak_temp - init_temp) / width) * y + (peak_temp + init_temp) / 2.0;
352};

◆ min_dt

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

Definition at line 317 of file thermoplastic.cpp.

◆ num_refinement_levels

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

Definition at line 321 of file thermoplastic.cpp.

◆ omega_0

double omega_0 = 2e-3

flow stress softening

Examples
thermoplastic.cpp.

Definition at line 294 of file thermoplastic.cpp.

◆ omega_h

double omega_h = 2e-3

hardening softening

Examples
thermoplastic.cpp.

Definition at line 295 of file thermoplastic.cpp.

◆ order

int order = 2

Order displacement.

Definition at line 300 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 285 of file thermoplastic.cpp.

◆ poisson_ratio

double poisson_ratio = 0.31

Poisson ratio.

Definition at line 266 of file thermoplastic.cpp.

◆ post_processing_counter

int post_processing_counter = 0
Examples
thermoplastic.cpp.

Definition at line 411 of file thermoplastic.cpp.

◆ prev_mesh_bit

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

Definition at line 336 of file thermoplastic.cpp.

◆ Qinf

double Qinf = 174.2

Saturation yield stress.

Definition at line 271 of file thermoplastic.cpp.

◆ qual_thresh

double qual_thresh = 0.1
Examples
thermoplastic.cpp.

Definition at line 319 of file thermoplastic.cpp.

◆ qual_tol

double qual_tol = 0
Examples
thermoplastic.cpp.

Definition at line 318 of file thermoplastic.cpp.

◆ refined_bit

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

Definition at line 335 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 255 of file thermoplastic.cpp.

◆ restart_time

double restart_time = 0
Examples
thermoplastic.cpp.

Definition at line 254 of file thermoplastic.cpp.

◆ rho

double rho = 0.0

Definition at line 314 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 624 of file thermoplastic.cpp.

625 {
627 auto out_meshset = get_temp_meshset_ptr(moab);
628 CHKERR moab.add_entities(*out_meshset, r);
629 CHKERR moab.write_file(name.c_str(), "VTK", "", out_meshset->get_ptr(), 1);
631};

◆ scale

double scale = 1.
Examples
thermoplastic.cpp.

Definition at line 258 of file thermoplastic.cpp.

◆ set_timer

PetscBool set_timer = PETSC_FALSE

Set timer.

Definition at line 250 of file thermoplastic.cpp.

◆ sigmaY

double sigmaY = 936.2

Yield stress.

Definition at line 267 of file thermoplastic.cpp.

◆ size_symm

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

Definition at line 46 of file thermoplastic.cpp.

◆ SPACE_DIM

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

Definition at line 44 of file thermoplastic.cpp.

◆ storage_bit

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

Definition at line 338 of file thermoplastic.cpp.

◆ T_order

int T_order = order - 1

Order of ep field.

Examples
thermoplastic.cpp.

Definition at line 304 of file thermoplastic.cpp.

◆ tau_order

int tau_order = order - 2

Order of tau field.

Definition at line 301 of file thermoplastic.cpp.

◆ temp_0

double temp_0 = 20

reference temperature for thermal softening

Examples
thermoplastic.cpp.

Definition at line 298 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 4472 of file thermoplastic.cpp.

◆ ts_to_ctx

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

Definition at line 4198 of file thermoplastic.cpp.

◆ ts_to_rctx

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

Definition at line 703 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 354 of file thermoplastic.cpp.

355 { return init_temp; };

◆ virgin_mesh_bit

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

Definition at line 337 of file thermoplastic.cpp.

◆ visH

double visH = 0

Viscous hardening.

Definition at line 269 of file thermoplastic.cpp.

◆ width

double width = 10.0

Width of Gaussian distribution.

Examples
thermoplastic.cpp.

Definition at line 286 of file thermoplastic.cpp.

◆ young_modulus

double young_modulus = 115000

Young modulus.

Definition at line 265 of file thermoplastic.cpp.

◆ zeta

double zeta = 5e-2

regularisation parameter

Definition at line 270 of file thermoplastic.cpp.