63 ParallelComm *pcomm = ParallelComm::get_pcomm(&moab,
MYPCOMM_INDEX);
65 pcomm =
new ParallelComm(&moab, PETSC_COMM_WORLD);
67 PetscBool flg = PETSC_TRUE;
71 if (flg != PETSC_TRUE) {
72 SETERRQ(PETSC_COMM_SELF, 1,
"*** ERROR -my_file (MESH FILE NEEDED)");
77 if (flg != PETSC_TRUE) {
80 PetscInt bubble_order;
83 if (flg != PETSC_TRUE) {
89 PetscBool is_partitioned = PETSC_FALSE;
91 &is_partitioned, &flg);
94 if (is_partitioned == PETSC_TRUE) {
96 option =
"PARALLEL=BCAST_DELETE;PARALLEL_RESOLVE_SHARED_ENTS;PARTITION="
97 "PARALLEL_PARTITION;";
132 PetscPrintf(PETSC_COMM_WORLD,
"young_modulus = %4.2e \n",
young_modulus);
133 PetscPrintf(PETSC_COMM_WORLD,
"poisson_ratio = %4.2e \n",
poisson_ratio);
134 PetscPrintf(PETSC_COMM_WORLD,
"sIgma_y = %4.2e \n", cp.
sIgma_y);
135 PetscPrintf(PETSC_COMM_WORLD,
"H = %4.2e \n", cp.
H);
136 PetscPrintf(PETSC_COMM_WORLD,
"K = %4.2e \n", cp.
K);
137 PetscPrintf(PETSC_COMM_WORLD,
"phi = %4.2e \n", cp.
phi);
139 cp.
sTrain.resize(6,
false);
155 vector<BitRefLevel> bit_levels;
161 Range CubitSideSets_meshsets;
162 CHKERR m_field.get_cubit_meshsets(
SIDESET, CubitSideSets_meshsets);
191 m_field,
"MESH_NODE_POSITIONS");
192 CHKERR m_field.
loop_dofs(
"MESH_NODE_POSITIONS", ent_method_material, 0);
205 "PLASTIC",
"MESH_NODE_POSITIONS");
209 CHKERR MetaNeummanForces::addNeumannBCElements(m_field,
"DISPLACEMENT");
218 DMType dm_name =
"PLASTIC_PROB";
222 CHKERR DMCreate(PETSC_COMM_WORLD, &dm);
223 CHKERR DMSetType(dm, dm_name);
227 CHKERR DMSetFromOptions(dm);
244 CHKERR VecGhostUpdateBegin(
D, INSERT_VALUES, SCATTER_FORWARD);
245 CHKERR VecGhostUpdateEnd(
D, INSERT_VALUES, SCATTER_FORWARD);
247 CHKERR MatZeroEntries(Aij);
252 dirichlet_bc.methodsOp.push_back(
257 PetscBool bbar = PETSC_TRUE;
259 small_strain_plasticity.commonData.bBar = bbar;
262 small_strain_plasticity.feRhs.getOpPtrVector().push_back(
264 "DISPLACEMENT", small_strain_plasticity.commonData));
265 small_strain_plasticity.feRhs.getOpPtrVector().push_back(
267 m_field,
"DISPLACEMENT", small_strain_plasticity.commonData,
269 small_strain_plasticity.feRhs.getOpPtrVector().push_back(
271 "DISPLACEMENT", small_strain_plasticity.commonData));
272 small_strain_plasticity.feLhs.getOpPtrVector().push_back(
274 "DISPLACEMENT", small_strain_plasticity.commonData));
275 small_strain_plasticity.feLhs.getOpPtrVector().push_back(
277 m_field,
"DISPLACEMENT", small_strain_plasticity.commonData,
279 small_strain_plasticity.feLhs.getOpPtrVector().push_back(
281 "DISPLACEMENT", small_strain_plasticity.commonData));
282 small_strain_plasticity.feUpdate.getOpPtrVector().push_back(
284 "DISPLACEMENT", small_strain_plasticity.commonData));
285 small_strain_plasticity.feUpdate.getOpPtrVector().push_back(
287 m_field,
"DISPLACEMENT", small_strain_plasticity.commonData,
289 small_strain_plasticity.feUpdate.getOpPtrVector().push_back(
291 "DISPLACEMENT", small_strain_plasticity.commonData));
292 CHKERR small_strain_plasticity.createInternalVariablesTag();
296 boost::ptr_map<string, NeummanForcesSurface> neumann_forces;
297 boost::ptr_map<string, NodalForce> nodal_forces;
298 boost::ptr_map<string, EdgeForce> edge_forces;
302 CHKERR MetaNeummanForces::setMomentumFluxOperators(
303 m_field, neumann_forces, PETSC_NULL,
"DISPLACEMENT");
310 for (boost::ptr_map<string, NeummanForcesSurface>::iterator mit =
311 neumann_forces.begin();
312 mit != neumann_forces.end(); mit++) {
313 mit->second->methodsOp.push_back(
316 for (boost::ptr_map<string, NodalForce>::iterator mit =
317 nodal_forces.begin();
318 mit != nodal_forces.end(); mit++) {
319 mit->second->methodsOp.push_back(
322 for (boost::ptr_map<string, EdgeForce>::iterator mit =
324 mit != edge_forces.end(); mit++) {
325 mit->second->methodsOp.push_back(
336 boost::ptr_map<string, NeummanForcesSurface>::iterator fit;
337 fit = neumann_forces.begin();
338 for (; fit != neumann_forces.end(); fit++) {
340 dm, fit->first.c_str(), &fit->second->getLoopFe(), NULL, NULL);
342 fit = nodal_forces.begin();
343 for (; fit != nodal_forces.end(); fit++) {
345 dm, fit->first.c_str(), &fit->second->getLoopFe(), NULL, NULL);
347 fit = edge_forces.begin();
348 for (; fit != edge_forces.end(); fit++) {
350 dm, fit->first.c_str(), &fit->second->getLoopFe(), NULL, NULL);
354 &small_strain_plasticity.feRhs,
355 PETSC_NULL, PETSC_NULL);
363 dm,
"PLASTIC", &small_strain_plasticity.feLhs, NULL, NULL);
372 CHKERR SNESCreate(PETSC_COMM_WORLD, &snes);
377 CHKERR SNESSetFromOptions(snes);
382 CHKERR post_proc.generateReferenceElementMesh();
383 CHKERR post_proc.addFieldValuesPostProc(
"DISPLACEMENT");
384 CHKERR post_proc.addFieldValuesGradientPostProc(
"DISPLACEMENT");
385 CHKERR post_proc.addFieldValuesPostProc(
"MESH_NODE_POSITIONS");
389 double final_time = 1, delta_time = 0.1;
392 double delta_time0 = delta_time;
407 rval = moab.get_entities_by_type(meshset, MBVERTEX, nodes,
true);
409 node_set.merge(nodes);
411 PetscPrintf(PETSC_COMM_WORLD,
"Nb. nodes in load path: %u\n",
415 boost::shared_ptr<NumeredDofEntity_multiIndex> numered_dofs_rows =
416 problem_ptr->getNumeredDofsRows();
417 Range::iterator nit = node_set.begin();
418 for (; nit != node_set.end(); nit++) {
419 NumeredDofEntityByEnt::iterator dit, hi_dit;
420 dit = numered_dofs_rows->get<
Ent_mi_tag>().lower_bound(*nit);
421 hi_dit = numered_dofs_rows->get<
Ent_mi_tag>().upper_bound(*nit);
422 for (; dit != hi_dit; dit++) {
423 load_path_dofs_view.insert(*dit);
430 SNESConvergedReason reason = SNES_CONVERGED_ITERATING;
431 for (;
t < final_time; step++) {
434 PetscPrintf(PETSC_COMM_WORLD,
"Step %d Time %6.4g final time %3.2g\n",
435 step,
t, final_time);
439 dirichlet_bc.ts_t =
t;
441 boost::ptr_map<string, NeummanForcesSurface>::iterator fit;
442 fit = neumann_forces.begin();
443 for (; fit != neumann_forces.end(); fit++) {
444 fit->second->getLoopFe().ts_t =
t;
446 fit = nodal_forces.begin();
447 for (; fit != nodal_forces.end(); fit++) {
448 fit->second->getLoopFe().ts_t =
t;
450 fit = edge_forces.begin();
451 for (; fit != edge_forces.end(); fit++) {
452 fit->second->getLoopFe().ts_t =
t;
464 if (step == 0 || reason < 0) {
465 CHKERR SNESSetLagJacobian(snes, -2);
467 CHKERR SNESSetLagJacobian(snes, -1);
469 CHKERR SNESSolve(snes, PETSC_NULL,
D);
472 CHKERR SNESGetIterationNumber(snes, &its);
478 CHKERR PetscPrintf(PETSC_COMM_WORLD,
479 "number of Newton iterations = %D\n", its);
481 CHKERR SNESGetConvergedReason(snes, &reason);
489 const double gamma = 0.5;
490 const double max_reudction = 1;
491 const double min_reduction = 1e-1;
493 reduction = pow((
double)its_d / (
double)(its + 1), gamma);
494 if (delta_time >= max_reudction * delta_time0 && reduction > 1) {
496 }
else if (delta_time <= min_reduction * delta_time0 &&
503 "reduction delta_time = %6.4e delta_time = %6.4e\n",
504 reduction, delta_time);
505 delta_time *= reduction;
506 if (reduction > 1 && delta_time < min_reduction * delta_time0) {
507 delta_time = min_reduction * delta_time0;
513 dm,
"PLASTIC", &small_strain_plasticity.feUpdate);
518 NumeredDofEntity_multiIndex_uid_view_ordered::iterator it,
520 it = load_path_dofs_view.begin();
521 hi_it = load_path_dofs_view.end();
522 for (; it != hi_it; it++) {
523 PetscPrintf(PETSC_COMM_WORLD,
524 "load_path %s [ %d ] %6.4e %6.4e %6.4e\n",
525 (*it)->getName().c_str(),
527 (*it)->getDofCoeffIdx(), (*it)->getFieldData(),
t,
537 std::ostringstream stm;
538 stm <<
"out_" << step <<
".h5m";
541 CHKERR PetscPrintf(PETSC_COMM_WORLD,
"out file %s\n",
543 rval = post_proc.postProcMesh.write_file(