v0.14.0
Public Member Functions | Public Attributes | List of all members
FractureMechanics::ConstantArea::MyTriangleFE Struct Reference

#include <users_modules/fracture_mechanics/src/ConstantArea.hpp>

Inheritance diagram for FractureMechanics::ConstantArea::MyTriangleFE:
[legend]
Collaboration diagram for FractureMechanics::ConstantArea::MyTriangleFE:
[legend]

Public Member Functions

 MyTriangleFE (MoFEM::Interface &m_field, CommonData &common_data, std::string field_name="LAMBDA_CRACKFRONT_AREA")
 
int getRule (int order)
 
PetscErrorCode preProcess ()
 
PetscErrorCode postProcess ()
 

Public Attributes

CommonDatacommonData
 
std::string fieldName
 
Mat petscB
 
Vec petscF
 
Mat petscQ
 

Detailed Description

Definition at line 52 of file ConstantArea.hpp.

Constructor & Destructor Documentation

◆ MyTriangleFE()

FractureMechanics::ConstantArea::MyTriangleFE::MyTriangleFE ( MoFEM::Interface m_field,
CommonData common_data,
std::string  field_name = "LAMBDA_CRACKFRONT_AREA" 
)
inline

Definition at line 61 of file ConstantArea.hpp.

63  : FaceElementForcesAndSourcesCore(m_field), commonData(common_data),
64  fieldName(field_name), petscB(PETSC_NULL), petscF(PETSC_NULL),
65  petscQ(PETSC_NULL) {}

Member Function Documentation

◆ getRule()

int FractureMechanics::ConstantArea::MyTriangleFE::getRule ( int  order)
inline

Definition at line 66 of file ConstantArea.hpp.

66 { return order; };

◆ postProcess()

PetscErrorCode FractureMechanics::ConstantArea::MyTriangleFE::postProcess ( )
inline

Definition at line 132 of file ConstantArea.hpp.

132  {
134  CHKERR FaceElementForcesAndSourcesCore::postProcess();
135  if (petscQ != PETSC_NULL) {
136  if (petscB == PETSC_NULL) {
137  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
138  "Matrix B should be set");
139  }
140 
141  // Q vectors
142  void *void_ctx;
143  CHKERR MatShellGetContext(petscQ, &void_ctx);
144  ConstrainMatrixCtx *q_mat_ctx = (ConstrainMatrixCtx *)void_ctx;
145 
146  Vec Qv;
147  CHKERR mField.getInterface<VecManager>()->vecCreateGhost(
148  problemPtr->getName(), COL, &Qv);
149  CHKERR MatAssemblyBegin(petscB, MAT_FLUSH_ASSEMBLY);
150  CHKERR MatAssemblyEnd(petscB, MAT_FLUSH_ASSEMBLY);
151  auto project_vectors_and_assemble = [this, Qv](auto dit) {
153  if (commonData.mapV.find(dit->get()->getPetscGlobalDofIdx()) ==
154  commonData.mapV.end()) {
155  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
156  "Vector on row not found");
157  }
158  CHKERR VecAssemblyBegin(
159  commonData.mapV[dit->get()->getPetscGlobalDofIdx()]);
160  CHKERR VecAssemblyEnd(
161  commonData.mapV[dit->get()->getPetscGlobalDofIdx()]);
162  CHKERR VecGhostUpdateBegin(
163  commonData.mapV[dit->get()->getPetscGlobalDofIdx()], ADD_VALUES,
164  SCATTER_REVERSE);
165  CHKERR VecGhostUpdateEnd(
166  commonData.mapV[dit->get()->getPetscGlobalDofIdx()], ADD_VALUES,
167  SCATTER_REVERSE);
168  CHKERR VecGhostUpdateBegin(
169  commonData.mapV[dit->get()->getPetscGlobalDofIdx()],
170  INSERT_VALUES, SCATTER_FORWARD);
171  CHKERR VecGhostUpdateEnd(
172  commonData.mapV[dit->get()->getPetscGlobalDofIdx()],
173  INSERT_VALUES, SCATTER_FORWARD);
174 
175  CHKERR MatMult(
176  petscQ, commonData.mapV[dit->get()->getPetscGlobalDofIdx()], Qv);
177  CHKERR VecGhostUpdateBegin(Qv, INSERT_VALUES, SCATTER_FORWARD);
178  CHKERR VecGhostUpdateEnd(Qv, INSERT_VALUES, SCATTER_FORWARD);
179 
180  if (0) {
181  auto save_vec = [](std::string name, Vec v) {
182  PetscViewer viewer;
183  PetscViewerASCIIOpen(PETSC_COMM_WORLD, name.c_str(), &viewer);
184  PetscViewerPushFormat(viewer, PETSC_VIEWER_ASCII_MATLAB);
185  VecView(v, viewer);
186  PetscViewerPopFormat(viewer);
187  PetscViewerDestroy(&viewer);
188  };
189  save_vec(
190  "V_" + boost::lexical_cast<std::string>(dit->get()->getEnt()) +
191  ".m",
192  commonData.mapV[dit->get()->getPetscGlobalDofIdx()]);
193  save_vec(
194  "Qv_" + boost::lexical_cast<std::string>(dit->get()->getEnt()) +
195  ".m",
196  Qv);
197  }
198 
199  if (dit->get()->getPart() == mField.get_comm_rank()) {
200  double *array;
201  CHKERR VecGetArray(Qv, &array);
202  vector<int> glob_idx;
203  vector<double> vals;
204  int row = dit->get()->getPetscGlobalDofIdx();
206  problemPtr,
207  mField.get_field_bit_number("MESH_NODE_POSITIONS"),
208  diit)) {
209  int idx = diit->get()->getPetscGlobalDofIdx();
210  double val = array[diit->get()->getPetscGlobalDofIdx()];
211  glob_idx.push_back(idx);
212  vals.push_back(val);
213  }
214  CHKERR MatSetValues(petscB, 1, &row, glob_idx.size(),
215  &*glob_idx.begin(), &*vals.begin(), ADD_VALUES);
216  CHKERR VecRestoreArray(Qv, &array);
217  }
218 
220  };
221 
223  problemPtr, mField.get_field_bit_number(fieldName), dit)) {
224  CHKERR project_vectors_and_assemble(dit);
225  CHKERR VecDestroy(
226  &commonData.mapV[dit->get()->getPetscGlobalDofIdx()]);
227  }
228 
229  CHKERR VecDestroy(&Qv);
230  commonData.mapV.clear();
231  }
232 
234  }

◆ preProcess()

PetscErrorCode FractureMechanics::ConstantArea::MyTriangleFE::preProcess ( )
inline

Definition at line 68 of file ConstantArea.hpp.

68  {
70  CHKERR FaceElementForcesAndSourcesCore::preProcess();
71 
72  if (petscB != PETSC_NULL) {
73  snes_B = petscB;
74  }
75 
76  if (petscF != PETSC_NULL) {
77  snes_f = petscF;
78  }
79 
80  switch (ts_ctx) {
81  case CTX_TSSETIFUNCTION: {
82  if (!petscF) {
83  snes_ctx = CTX_SNESSETFUNCTION;
84  snes_f = ts_F;
85  }
86  break;
87  }
88  case CTX_TSSETIJACOBIAN: {
89  if (!petscB) {
90  snes_ctx = CTX_SNESSETJACOBIAN;
91  snes_B = ts_B;
92  }
93  break;
94  }
95  default:
96  break;
97  }
98 
99  // Tag to detect which side is it
100  CHKERR mField.get_moab().tag_get_handle("INTERFACE_SIDE",
102 
103  // If petscQ matrix is defined appply projection to each row
104  if (petscQ != PETSC_NULL) {
105  if (petscB == PETSC_NULL) {
106  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
107  "Matrix B should be set");
108  }
109  const auto field_bit_number = mField.get_field_bit_number(fieldName);
110  for (_IT_NUMEREDDOF_ROW_BY_BITNUMBER_FOR_LOOP_(problemPtr, field_bit_number,
111  dit)) {
112  CHKERR mField.getInterface<VecManager>()->vecCreateGhost(
113  problemPtr->getName(), COL,
114  &commonData.mapV[dit->get()->getPetscGlobalDofIdx()]);
115  CHKERR VecZeroEntries(
116  commonData.mapV[dit->get()->getPetscGlobalDofIdx()]);
117  CHKERR VecGhostUpdateBegin(
118  commonData.mapV[dit->get()->getPetscGlobalDofIdx()],
119  INSERT_VALUES, SCATTER_FORWARD);
120  CHKERR VecGhostUpdateEnd(
121  commonData.mapV[dit->get()->getPetscGlobalDofIdx()],
122  INSERT_VALUES, SCATTER_FORWARD);
123  }
124  commonData.setMapV = true;
125  } else {
126  commonData.setMapV = false;
127  }
128 
130  }

Member Data Documentation

◆ commonData

CommonData& FractureMechanics::ConstantArea::MyTriangleFE::commonData

Definition at line 54 of file ConstantArea.hpp.

◆ fieldName

std::string FractureMechanics::ConstantArea::MyTriangleFE::fieldName

Definition at line 55 of file ConstantArea.hpp.

◆ petscB

Mat FractureMechanics::ConstantArea::MyTriangleFE::petscB

Definition at line 57 of file ConstantArea.hpp.

◆ petscF

Vec FractureMechanics::ConstantArea::MyTriangleFE::petscF

Definition at line 58 of file ConstantArea.hpp.

◆ petscQ

Mat FractureMechanics::ConstantArea::MyTriangleFE::petscQ

Definition at line 59 of file ConstantArea.hpp.


The documentation for this struct was generated from the following file:
MoFEM::UnknownInterface::getInterface
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface refernce to pointer of interface.
Definition: UnknownInterface.hpp:93
_IT_NUMEREDDOF_COL_BY_BITNUMBER_FOR_LOOP_
#define _IT_NUMEREDDOF_COL_BY_BITNUMBER_FOR_LOOP_(PROBLEMPTR, FIELD_BIT_NUMBER, IT)
use with loops to iterate col DOFs
Definition: ProblemsMultiIndices.hpp:358
FractureMechanics::ConstantArea::CommonData::setMapV
bool setMapV
Definition: ConstantArea.hpp:46
MoFEM::MatSetValues
MoFEMErrorCode MatSetValues(Mat M, const EntitiesFieldData::EntData &row_data, const EntitiesFieldData::EntData &col_data, const double *ptr, InsertMode iora)
Assemble PETSc matrix.
Definition: EntitiesFieldData.hpp:1631
FractureMechanics::ConstantArea::MyTriangleFE::petscQ
Mat petscQ
Definition: ConstantArea.hpp:59
MoFEM::CoreInterface::get_field_bit_number
virtual FieldBitNumber get_field_bit_number(const std::string name) const =0
get field bit number
MoFEM::CoreInterface::get_comm_rank
virtual int get_comm_rank() const =0
FractureMechanics::ConstantArea::CommonData::thInterfaceSide
Tag thInterfaceSide
Definition: ConstantArea.hpp:48
ts_ctx
MoFEM::TsCtx * ts_ctx
Definition: level_set.cpp:1932
FractureMechanics::ConstantArea::CommonData::mapV
map< int, Vec > mapV
Definition: ConstantArea.hpp:45
order
constexpr int order
Definition: dg_projection.cpp:18
CHKERR
#define CHKERR
Inline error check.
Definition: definitions.h:535
MoFEM::CoreInterface::get_moab
virtual moab::Interface & get_moab()=0
_IT_NUMEREDDOF_ROW_BY_BITNUMBER_FOR_LOOP_
#define _IT_NUMEREDDOF_ROW_BY_BITNUMBER_FOR_LOOP_(PROBLEMPTR, FIELD_BIT_NUMBER, IT)
Definition: ProblemsMultiIndices.hpp:338
FractureMechanics::ConstantArea::MyTriangleFE::petscB
Mat petscB
Definition: ConstantArea.hpp:57
FractureMechanics::ConstantArea::MyTriangleFE::petscF
Vec petscF
Definition: ConstantArea.hpp:58
COL
@ COL
Definition: definitions.h:123
FaceElementForcesAndSourcesCore
field_name
constexpr auto field_name
Definition: poisson_2d_homogeneous.cpp:13
FractureMechanics::ConstantArea::mField
MoFEM::Interface & mField
Definition: ConstantArea.hpp:28
FractureMechanics::ConstantArea::MyTriangleFE::fieldName
std::string fieldName
Definition: ConstantArea.hpp:55
FractureMechanics::ConstantArea::MyTriangleFE::commonData
CommonData & commonData
Definition: ConstantArea.hpp:54
v
const double v
phase velocity of light in medium (cm/ns)
Definition: initial_diffusion.cpp:40
EigenMatrix::Vec
const FTensor::Tensor2< T, Dim, Dim > Vec
Definition: MatrixFunction.hpp:66
MOFEM_DATA_INCONSISTENCY
@ MOFEM_DATA_INCONSISTENCY
Definition: definitions.h:31
ConstrainMatrixCtx
structure for projection matrices
Definition: ConstrainMatrixCtx.hpp:16
MoFEMFunctionReturn
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:416
MoFEMFunctionBegin
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:346