|
| v0.14.0
|
Go to the documentation of this file.
22 using namespace MoFEM;
24 #include <boost/program_options.hpp>
26 namespace po = boost::program_options;
28 #include <boost/numeric/ublas/vector_proxy.hpp>
29 #include <boost/numeric/ublas/matrix.hpp>
30 #include <boost/numeric/ublas/matrix_proxy.hpp>
31 #include <boost/numeric/ublas/vector.hpp>
32 #include <boost/numeric/ublas/symmetric.hpp>
34 #include <adolc/adolc.h>
50 using namespace boost::numeric;
52 static char help[] =
"...\n"
55 int main(
int argc,
char *argv[]) {
62 ParallelComm *pcomm = ParallelComm::get_pcomm(&moab,
MYPCOMM_INDEX);
64 pcomm =
new ParallelComm(&moab, PETSC_COMM_WORLD);
66 PetscBool flg = PETSC_TRUE;
70 if (flg != PETSC_TRUE) {
71 SETERRQ(PETSC_COMM_SELF, 1,
"*** ERROR -my_file (MESH FILE NEEDED)");
76 if (flg != PETSC_TRUE) {
79 PetscInt bubble_order;
82 if (flg != PETSC_TRUE) {
88 PetscBool is_partitioned = PETSC_FALSE;
90 &is_partitioned, &flg);
93 if (is_partitioned == PETSC_TRUE) {
95 option =
"PARALLEL=BCAST_DELETE;PARALLEL_RESOLVE_SHARED_ENTS;PARTITION="
96 "PARALLEL_PARTITION;";
141 PetscPrintf(PETSC_COMM_WORLD,
"young_modulus = %4.2e \n",
young_modulus);
142 PetscPrintf(PETSC_COMM_WORLD,
"poisson_ratio = %4.2e \n",
poisson_ratio);
144 PetscPrintf(PETSC_COMM_WORLD,
"sIgma_yt = %4.2e \n", cp.
sIgma_yt);
145 PetscPrintf(PETSC_COMM_WORLD,
"sIgma_yc = %4.2e \n", cp.
sIgma_yt);
147 PetscPrintf(PETSC_COMM_WORLD,
"nup = %4.2e \n", cp.
nup);
149 cp.
sTrain.resize(6,
false);
165 vector<BitRefLevel> bit_levels;
171 Range CubitSideSets_meshsets;
172 CHKERR m_field.get_cubit_meshsets(
SIDESET, CubitSideSets_meshsets);
201 m_field,
"MESH_NODE_POSITIONS");
202 CHKERR m_field.
loop_dofs(
"MESH_NODE_POSITIONS", ent_method_material, 0);
215 "PLASTIC",
"MESH_NODE_POSITIONS");
219 CHKERR MetaNeummanForces::addNeumannBCElements(m_field,
"DISPLACEMENT");
228 DMType dm_name =
"PLASTIC_PROB";
232 CHKERR DMCreate(PETSC_COMM_WORLD, &dm);
233 CHKERR DMSetType(dm, dm_name);
237 CHKERR DMSetFromOptions(dm);
254 CHKERR VecGhostUpdateBegin(
D, INSERT_VALUES, SCATTER_FORWARD);
255 CHKERR VecGhostUpdateEnd(
D, INSERT_VALUES, SCATTER_FORWARD);
257 CHKERR MatZeroEntries(Aij);
267 PetscBool bbar = PETSC_TRUE;
274 "DISPLACEMENT", small_strain_plasticity.
commonData));
277 m_field,
"DISPLACEMENT", small_strain_plasticity.
commonData, cp,
281 "DISPLACEMENT", small_strain_plasticity.
commonData));
284 "DISPLACEMENT", small_strain_plasticity.
commonData));
287 m_field,
"DISPLACEMENT", small_strain_plasticity.
commonData, cp,
291 "DISPLACEMENT", small_strain_plasticity.
commonData));
294 "DISPLACEMENT", small_strain_plasticity.
commonData));
297 m_field,
"DISPLACEMENT", small_strain_plasticity.
commonData, cp,
301 "DISPLACEMENT", small_strain_plasticity.
commonData));
306 boost::ptr_map<string, NeummanForcesSurface> neumann_forces;
307 boost::ptr_map<string, NodalForce> nodal_forces;
308 boost::ptr_map<string, EdgeForce> edge_forces;
312 CHKERR MetaNeummanForces::setMomentumFluxOperators(
313 m_field, neumann_forces, PETSC_NULL,
"DISPLACEMENT");
320 for (boost::ptr_map<string, NeummanForcesSurface>::iterator mit =
321 neumann_forces.begin();
322 mit != neumann_forces.end(); mit++) {
323 mit->second->methodsOp.push_back(
326 for (boost::ptr_map<string, NodalForce>::iterator mit =
327 nodal_forces.begin();
328 mit != nodal_forces.end(); mit++) {
329 mit->second->methodsOp.push_back(
332 for (boost::ptr_map<string, EdgeForce>::iterator mit =
334 mit != edge_forces.end(); mit++) {
335 mit->second->methodsOp.push_back(
346 boost::ptr_map<string, NeummanForcesSurface>::iterator fit;
347 fit = neumann_forces.begin();
348 for (; fit != neumann_forces.end(); fit++) {
350 dm, fit->first.c_str(), &fit->second->getLoopFe(), NULL, NULL);
352 fit = nodal_forces.begin();
353 for (; fit != nodal_forces.end(); fit++) {
355 dm, fit->first.c_str(), &fit->second->getLoopFe(), NULL, NULL);
357 fit = edge_forces.begin();
358 for (; fit != edge_forces.end(); fit++) {
360 dm, fit->first.c_str(), &fit->second->getLoopFe(), NULL, NULL);
364 &small_strain_plasticity.
feRhs,
365 PETSC_NULL, PETSC_NULL);
373 dm,
"PLASTIC", &small_strain_plasticity.
feLhs, NULL, NULL);
382 CHKERR SNESCreate(PETSC_COMM_WORLD, &snes);
387 CHKERR SNESSetFromOptions(snes);
399 double final_time = 1, delta_time = 0.1;
402 double delta_time0 = delta_time;
417 rval = moab.get_entities_by_type(meshset, MBVERTEX, nodes,
true);
419 node_set.merge(nodes);
421 PetscPrintf(PETSC_COMM_WORLD,
"Nb. nodes in load path: %u\n",
425 boost::shared_ptr<NumeredDofEntity_multiIndex> numered_dofs_rows =
426 problem_ptr->getNumeredDofsRows();
427 Range::iterator nit = node_set.begin();
428 for (; nit != node_set.end(); nit++) {
429 NumeredDofEntityByEnt::iterator dit, hi_dit;
430 dit = numered_dofs_rows->get<
Ent_mi_tag>().lower_bound(*nit);
431 hi_dit = numered_dofs_rows->get<
Ent_mi_tag>().upper_bound(*nit);
432 for (; dit != hi_dit; dit++) {
433 load_path_dofs_view.insert(*dit);
440 SNESConvergedReason reason = SNES_CONVERGED_ITERATING;
441 for (;
t < final_time; step++) {
444 PetscPrintf(PETSC_COMM_WORLD,
"Step %d Time %6.4g final time %3.2g\n",
445 step,
t, final_time);
449 dirichlet_bc.
ts_t =
t;
451 boost::ptr_map<string, NeummanForcesSurface>::iterator fit;
452 fit = neumann_forces.begin();
453 for (; fit != neumann_forces.end(); fit++) {
454 fit->second->getLoopFe().ts_t =
t;
456 fit = nodal_forces.begin();
457 for (; fit != nodal_forces.end(); fit++) {
458 fit->second->getLoopFe().ts_t =
t;
460 fit = edge_forces.begin();
461 for (; fit != edge_forces.end(); fit++) {
462 fit->second->getLoopFe().ts_t =
t;
474 if (step == 0 || reason < 0) {
475 CHKERR SNESSetLagJacobian(snes, -2);
477 CHKERR SNESSetLagJacobian(snes, -1);
479 CHKERR SNESSolve(snes, PETSC_NULL,
D);
482 CHKERR SNESGetIterationNumber(snes, &its);
488 CHKERR PetscPrintf(PETSC_COMM_WORLD,
489 "number of Newton iterations = %D\n", its);
491 CHKERR SNESGetConvergedReason(snes, &reason);
499 const double gamma = 0.5;
500 const double max_reudction = 1;
501 const double min_reduction = 1e-1;
503 reduction = pow((
double)its_d / (
double)(its + 1), gamma);
504 if (delta_time >= max_reudction * delta_time0 && reduction > 1) {
506 }
else if (delta_time <= min_reduction * delta_time0 &&
513 "reduction delta_time = %6.4e delta_time = %6.4e\n",
514 reduction, delta_time);
515 delta_time *= reduction;
516 if (reduction > 1 && delta_time < min_reduction * delta_time0) {
517 delta_time = min_reduction * delta_time0;
523 dm,
"PLASTIC", &small_strain_plasticity.
feUpdate);
528 NumeredDofEntity_multiIndex_uid_view_ordered::iterator it,
530 it = load_path_dofs_view.begin();
531 hi_it = load_path_dofs_view.end();
532 for (; it != hi_it; it++) {
533 PetscPrintf(PETSC_COMM_WORLD,
534 "load_path %s [ %d ] %6.4e %6.4e %6.4e\n",
535 (*it)->getName().c_str(), (*it)->getDofCoeffIdx(),
536 (*it)->getFieldData(),
t,
scale);
545 std::ostringstream stm;
546 stm <<
"out_" << step <<
".h5m";
549 CHKERR PetscPrintf(PETSC_COMM_WORLD,
"out file %s\n",
#define MYPCOMM_INDEX
default communicator number PCOMM
virtual MoFEMErrorCode loop_dofs(const Problem *problem_ptr, const std::string &field_name, RowColData rc, DofMethod &method, int lower_rank, int upper_rank, int verb=DEFAULT_VERBOSITY)=0
Make a loop over dofs.
double young_modulus
Young modulus.
moab::Interface & postProcMesh
#define CHKERRQ_MOAB(a)
check error code of MoAB function
Small strain plasticity with paraboloidal yield criterion (Isotropic Hardening)
virtual MoFEMErrorCode modify_finite_element_add_field_row(const std::string &fe_name, const std::string name_row)=0
set field row which finite element use
VectorDouble plasticStrain
virtual const Problem * get_problem(const std::string problem_name) const =0
Get the problem object.
PetscErrorCode DMoFEMMeshToLocalVector(DM dm, Vec l, InsertMode mode, ScatterMode scatter_mode)
set local (or ghosted) vector values on mesh for partition only
Projection of edge entities with one mid-node on hierarchical basis.
static MoFEMErrorCode Finalize()
Checks for options to be called at the conclusion of the program.
PetscErrorCode snesCreate()
Set Dirichlet boundary conditions on displacements.
virtual PetscErrorCode createMatAVecR()
virtual MoFEMErrorCode add_ents_to_field_by_type(const Range &ents, const EntityType type, const std::string &name, int verb=DEFAULT_VERBOSITY)=0
Add entities to field meshset.
PetscErrorCode DMMoFEMAddElement(DM dm, std::string fe_name)
add element to dm
Deprecated interface functions.
DeprecatedCoreInterface Interface
PetscErrorCode DMCreateGlobalVector_MoFEM(DM dm, Vec *g)
DMShellSetCreateGlobalVector.
virtual MoFEMErrorCode add_ents_to_finite_element_by_type(const EntityHandle entities, const EntityType type, const std::string &name, const bool recursive=true)=0
add entities to finite element
static MoFEMErrorCodeGeneric< moab::ErrorCode > rval
PetscErrorCode DMCreateMatrix_MoFEM(DM dm, Mat *M)
#define CHKERR
Inline error check.
virtual MoFEMErrorCode add_finite_element(const std::string &fe_name, enum MoFEMTypes bh=MF_EXCL, int verb=DEFAULT_VERBOSITY)=0
add finite element
implementation of Data Operators for Forces and Sources
virtual MoFEMErrorCode modify_finite_element_add_field_col(const std::string &fe_name, const std::string name_row)=0
set field col which finite element use
Force scale operator for reading two columns.
PetscErrorCode PetscOptionsGetReal(PetscOptions *, const char pre[], const char name[], PetscReal *dval, PetscBool *set)
virtual MoFEMErrorCode build_finite_elements(int verb=DEFAULT_VERBOSITY)=0
Build finite elements.
virtual MoFEMErrorCode add_field(const std::string &name, const FieldSpace space, const FieldApproximationBase base, const FieldCoefficientsNumber nb_of_coefficients, const TagType tag_type=MB_TAG_SPARSE, const enum MoFEMTypes bh=MF_EXCL, int verb=DEFAULT_VERBOSITY)=0
Add field.
PetscErrorCode DMoFEMMeshToGlobalVector(DM dm, Vec g, InsertMode mode, ScatterMode scatter_mode)
set ghosted vector values on all existing mesh entities
PetscErrorCode DMMoFEMGetSnesCtx(DM dm, MoFEM::SnesCtx **snes_ctx)
get MoFEM::SnesCtx data structure
multi_index_container< boost::shared_ptr< NumeredDofEntity >, indexed_by< ordered_unique< const_mem_fun< NumeredDofEntity::interface_type_DofEntity, UId, &NumeredDofEntity::getLocalUniqueId > > > > NumeredDofEntity_multiIndex_uid_view_ordered
PetscErrorCode DMRegister_MoFEM(const char sname[])
Register MoFEM problem.
Small Strain plasticity material models.
double poisson_ratio
Poisson ratio.
PetscErrorCode DMMoFEMSNESSetJacobian(DM dm, const char fe_name[], MoFEM::FEMethod *method, MoFEM::BasicMethod *pre_only, MoFEM::BasicMethod *post_only)
set SNES Jacobian evaluation function
MoFEMErrorCode generateReferenceElementMesh()
Generate reference mesh on single element.
MoFEMErrorCode addFieldValuesGradientPostProc(const std::string field_name, Vec v=PETSC_NULL)
Add operator to post-process L2 or H1 field gradient.
Post-process fields on refined mesh.
constexpr double t
plate stiffness
Small strain finite element implementation.
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.
Operators and data structures for small strain plasticity.
VectorDouble internalVariables
PetscErrorCode SnesRhs(SNES snes, Vec x, Vec f, void *ctx)
This is MoFEM implementation for the right hand side (residual vector) evaluation in SNES solver.
static MoFEMErrorCode Initialize(int *argc, char ***args, const char file[], const char help[])
Initializes the MoFEM database PETSc, MOAB and MPI.
MoFEMErrorCode getForceScale(const double ts_t, double &scale)
#define CATCH_ERRORS
Catch errors.
PetscErrorCode createInternalVariablesTag()
@ AINSWORTH_LEGENDRE_BASE
Ainsworth Cole (Legendre) approx. base .
boost::ptr_deque< UserDataOperator > & getOpPtrVector()
Use to push back operator for row operator.
const FTensor::Tensor2< T, Dim, Dim > Vec
PetscErrorCode PetscOptionsGetString(PetscOptions *, const char pre[], const char name[], char str[], size_t size, PetscBool *set)
virtual MoFEMErrorCode build_fields(int verb=DEFAULT_VERBOSITY)=0
DEPRECATED MoFEMErrorCode seed_ref_level_3D(const EntityHandle meshset, const BitRefLevel &bit, int verb=-1)
seed 2D entities in the meshset and their adjacencies (only TETs adjacencies) in a particular BitRefL...
boost::ptr_vector< MethodForForceScaling > methodsOp
virtual MoFEMErrorCode modify_finite_element_add_field_data(const std::string &fe_name, const std::string name_filed)=0
set finite element field data
#define _IT_CUBITMESHSETS_BY_NAME_FOR_LOOP_(MESHSET_MANAGER, NAME, IT)
Iterator that loops over Cubit BlockSet having a particular name.
const double D
diffusivity
std::bitset< BITREFLEVEL_SIZE > BitRefLevel
Bit structure attached to each entity identifying to what mesh entity is attached.
virtual MoFEMErrorCode build_adjacencies(const Range &ents, int verb=DEFAULT_VERBOSITY)=0
build adjacencies
MyVolumeFE feRhs
calculate right hand side for tetrahedral elements
int main(int argc, char *argv[])
Interface for nonlinear (SNES) solver.
keeps basic data about problem
virtual MoFEMErrorCode set_field_order(const EntityHandle meshset, const EntityType type, const std::string &name, const ApproximationOrder order, int verb=DEFAULT_VERBOSITY)=0
Set order approximation of the entities in the field.
PetscErrorCode SnesMat(SNES snes, Vec x, Mat A, Mat B, void *ctx)
This is MoFEM implementation for the left hand side (tangent matrix) evaluation in SNES solver.
PetscErrorCode DMoFEMLoopFiniteElements(DM dm, const char fe_name[], MoFEM::FEMethod *method, CacheTupleWeakPtr cache_ptr=CacheTupleSharedPtr())
Executes FEMethod for finite elements in DM.
PetscErrorCode PetscOptionsGetInt(PetscOptions *, const char pre[], const char name[], PetscInt *ivalue, PetscBool *set)
PetscErrorCode DMMoFEMSetIsPartitioned(DM dm, PetscBool is_partitioned)
PetscErrorCode DMMoFEMSNESSetFunction(DM dm, const char fe_name[], MoFEM::FEMethod *method, MoFEM::BasicMethod *pre_only, MoFEM::BasicMethod *post_only)
set SNES residual evaluation function
PetscErrorCode PetscOptionsGetBool(PetscOptions *, const char pre[], const char name[], PetscBool *bval, PetscBool *set)
MoFEMErrorCode addFieldValuesPostProc(const std::string field_name, Vec v=PETSC_NULL)
Add operator to post-process L2, H1, Hdiv, Hcurl field value.