v0.13.0
MultifieldPlasticity.hpp
Go to the documentation of this file.
1 /** \file MultifieldPlasticity
2  * \brief Multifield plasticity
3 
4 */
5 
6 /* This file is part of MoFEM.
7  * MoFEM is free software: you can redistribute it and/or modify it under
8  * the terms of the GNU Lesser General Public License as published by the
9  * Free Software Foundation, either version 3 of the License, or (at your
10  * option) any later version.
11  *
12  * MoFEM is distributed in the hope that it will be useful, but WITHOUT
13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
15  * License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with MoFEM. If not, see <http://www.gnu.org/licenses/>. */
19 
20 namespace MoFEM {
21 
22 extern boost::weak_ptr<BlockMatContainer> block_mat_container_ptr;
23 
24 template <typename EleOp>
25 struct OpBaseImpl<USER_ASSEMBLE, EleOp>
26  : public OpBaseImpl<LAST_ASSEMBLE, EleOp> {
28 
29 protected:
30 
33  const bool transpose) {
35 
36  if (transpose) {
37  this->locMatTranspose.resize(this->locMat.size2(), this->locMat.size1(),
38  false);
39  noalias(this->locMatTranspose) = trans(this->locMat);
40  }
41 
42  if (auto bmc_ptr = block_mat_container_ptr.lock()) {
43  // if (true) {
44  // if (this->rowFieldName == "SIGMA" || this->colFieldName == "SIGMA") {
45  // // cout << "WE ARE ADDING THE BLOCK" << endl;
46  // // cout << this->rowFieldName << " " << this->colFieldName << endl;
47 
48  // }
49  auto &bmc = *bmc_ptr;
50  int *row_ind_ptr = &*row_data.getIndices().begin();
51  int *col_ind_ptr = &*col_data.getIndices().begin();
52  int row_nb_dofs = row_data.getIndices().size();
53  int col_nb_dofs = col_data.getIndices().size();
54  auto &K = this->locMat;
55  auto &transK = this->locMatTranspose;
56 
57  auto set_block = [&](auto &row_name, auto &col_name, auto row_side,
58  auto col_side, auto row_type, auto col_type,
59  const auto &m, const auto &row_ind,
60  const auto &col_ind) {
61  auto it = bmc.get<0>().find(boost::make_tuple(
62  row_name, col_name, row_type, col_type, row_side, col_side));
63  if (it != bmc.get<0>().end()) {
64  it->setMat(m);
65  it->setInd(row_ind, col_ind);
66  it->setSetAtElement();
67  } else
68  bmc.insert(BlockMatData(row_name, col_name, row_type, col_type,
69  row_side, col_side, m, row_ind, col_ind));
70  };
71  if (this->rowFieldName != "SIGMA" && this->colFieldName != "SIGMA") {
72  if (auto e_ptr = row_data.getFieldEntities()[0]) {
73  if (auto stored_data_ptr =
74  e_ptr->getSharedStoragePtr<EssentialBcStorage>()) {
75  if (!this->onlyTranspose)
76  set_block(this->rowFieldName, this->colFieldName, this->rowSide,
77  this->colSide, this->rowType, this->colType, K,
78  stored_data_ptr->entityIndices, col_data.getIndices());
79  if (transpose)
80  set_block(this->colFieldName, this->rowFieldName, this->colSide,
81  this->rowSide, this->colType, this->rowType, transK,
82  col_data.getIndices(), stored_data_ptr->entityIndices);
83  } else {
84  if (!this->onlyTranspose)
85  set_block(this->rowFieldName, this->colFieldName, this->rowSide,
86  this->colSide, this->rowType, this->colType, K,
87  row_data.getIndices(), col_data.getIndices());
88 
89  if (transpose)
90  set_block(this->colFieldName, this->rowFieldName, this->colSide,
91  this->rowSide, this->colType, this->rowType, transK,
92  col_data.getIndices(), row_data.getIndices());
93  }
94  } else
95  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
96  "No field entities for assembly");
97  }
98  }
99 
100  // Assemble transpose
101  if (transpose) {
103  this->getKSPB(), col_data, row_data,
104  &*this->locMatTranspose.data().begin(), ADD_VALUES);
105  }
106 
107  if (!this->onlyTranspose) {
108  // assemble local matrix
110  this->getKSPB(), row_data, col_data, &*this->locMat.data().begin(),
111  ADD_VALUES);
112  }
113 
115  }
116 
119  this->getKSPf(), data, &*this->locF.data().begin(), ADD_VALUES);
120  }
121 };
122 
124 
129 
134 
139 
144 
145 
147  SmartPetscObj<DM> &dm,
148  SmartPetscObj<DM> &dm_plastic);
150  SmartPetscObj<DM> &dm,
151  SmartPetscObj<DM> &dm_plastic_tau);
153  SmartPetscObj<DM> &dm_contact);
154 
155 } // namespace MoFEM
ForcesAndSourcesCore::UserDataOperator UserDataOperator
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:359
@ MOFEM_DATA_INCONSISTENCY
Definition: definitions.h:44
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:429
#define CHKERR
Inline error check.
Definition: definitions.h:548
FaceElementForcesAndSourcesCoreSwitch< 0 > FaceElementForcesAndSourcesCore
Face finite element default.
VolumeElementForcesAndSourcesCoreOnSideSwitch< 0 > VolumeElementForcesAndSourcesCoreOnSide
Volume element used to integrate on skeleton.
VolumeElementForcesAndSourcesCoreSwitch< 0 > VolumeElementForcesAndSourcesCore
Volume finite element default.
MoFEMErrorCode VecSetValues< EssentialBcStorage >(Vec V, const EntitiesFieldData::EntData &data, const double *ptr, InsertMode iora)
Set values to vector in operator.
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
Definition: Exceptions.hpp:67
implementation of Data Operators for Forces and Sources
Definition: Common.hpp:21
MoFEMErrorCode set_contact_dm(MoFEM::Interface &m_field, SmartPetscObj< DM > &dm, SmartPetscObj< DM > &dm_contact)
DataForcesAndSourcesCore::EntData EntData
boost::weak_ptr< BlockMatContainer > block_mat_container_ptr
MoFEMErrorCode MatSetValues< EssentialBcStorage >(Mat M, const EntitiesFieldData::EntData &row_data, const EntitiesFieldData::EntData &col_data, const double *ptr, InsertMode iora)
Set values to matrix in operator.
FaceElementForcesAndSourcesCore BoundaryEle
FaceElementForcesAndSourcesCore SkeletonEle
MoFEMErrorCode set_plastic_tau_dm(MoFEM::Interface &m_field, SmartPetscObj< DM > &dm, SmartPetscObj< DM > &dm_plastic_tau)
MoFEMErrorCode set_plastic_ep_dm(MoFEM::Interface &m_field, SmartPetscObj< DM > &dm, SmartPetscObj< DM > &dm_plastic)
OpBaseImpl< PETSC, EdgeEleOp > OpBase
Definition: radiation.cpp:41
FTensor::Index< 'm', 3 > m
Deprecated interface functions.
[Storage and set boundary conditions]
MoFEMErrorCode aSsemble(DataForcesAndSourcesCore::EntData &data)
MoFEMErrorCode aSsemble(DataForcesAndSourcesCore::EntData &row_data, DataForcesAndSourcesCore::EntData &col_data, const bool transpose)
VectorDouble locF
local entity vector
MatrixDouble locMatTranspose
local entity block matrix
int rowSide
row side number
int colSide
column side number
EntityType colType
column type
MatrixDouble locMat
local entity block matrix
EntityType rowType
row type
VolumeElementForcesAndSourcesCoreOnSideBase::UserDataOperator UserDataOperator
VolumeElementForcesAndSourcesCoreBase::UserDataOperator UserDataOperator