v0.14.0
Public Member Functions | Public Attributes | List of all members
ObosleteUsersModules::ConstrainConstantAarea Struct Reference

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

Inheritance diagram for ObosleteUsersModules::ConstrainConstantAarea:
[legend]
Collaboration diagram for ObosleteUsersModules::ConstrainConstantAarea:
[legend]

Public Member Functions

 ConstrainConstantAarea (MoFEM::Interface &m_field, Mat _C, Mat _Q, string lambda_field_name, int _verbose=0)
 
virtual ~ConstrainConstantAarea ()=default
 
template<typename DOFS >
auto loIt (DOFS dofs, const FieldBitNumber bit, const EntityHandle ent)
 
template<typename DOFS >
auto hiIt (DOFS dofs, const FieldBitNumber bit, const EntityHandle ent)
 
PetscErrorCode getData (bool is_that_C_otherwise_dC, bool trans)
 get face data, indices and coors and nodal values More...
 
PetscErrorCode calcDirevatives (double *diffNTRI, double *dofs_X, double *dofs_iX, double *C, double *iC, double *T, double *iT)
 calculate direvatives More...
 
PetscErrorCode preProcess ()
 
PetscErrorCode operator() ()
 
PetscErrorCode postProcess ()
 

Public Attributes

MoFEM::InterfacemField
 
moab::Interface & moab
 
Mat C
 
Mat Q
 
string lambdaFieldName
 
int verbose
 
MatrixDouble diffNTRI
 
const doubleG_TRI_W
 
vector< DofIdx > DirichletBC
 
VectorInt dispDofsColIdx
 
VectorInt dispDofsRowIdx
 
VectorInt localDispDofsRowIdx
 
VectorInt lambdaDofsRowIdx
 
VectorInt lambdaDofsColIdx
 
ublas::vector< double, ublas::bounded_array< double, 9 > > coords
 
ublas::vector< double, ublas::bounded_array< double, 9 > > dofs_X
 
ublas::vector< double, ublas::bounded_array< double, 3 > > lambda
 
EntityHandle face
 
Range problemTets
 
map< DofIdx, Vec > mapV
 

Detailed Description

dN/dX = (1/A) * [ Spin[dX/dksi]*dN/deta - Spin[dX/deta]*dN/dksi ]

Definition at line 37 of file ComplexConstArea.hpp.

Constructor & Destructor Documentation

◆ ConstrainConstantAarea()

ObosleteUsersModules::ConstrainConstantAarea::ConstrainConstantAarea ( MoFEM::Interface m_field,
Mat  _C,
Mat  _Q,
string  lambda_field_name,
int  _verbose = 0 
)
inline

Definition at line 48 of file ComplexConstArea.hpp.

50  : mField(m_field), moab(m_field.get_moab()), C(_C), Q(_Q),
51  lambdaFieldName(lambda_field_name), verbose(_verbose) {
52  // calculate face shape functions direvatives
53  diffNTRI.resize(3, 2);
54  ShapeDiffMBTRI(&*diffNTRI.data().begin());
55  // shape functions Gauss integration weigths
56  G_TRI_W = G_TRI_W1;
57  // nodal material positions
58  dofs_X.resize(9);
59  // noal values of Lagrange multipliers
60  lambda.resize(3);
61  // dofs indices for Lagrnage multipliers
62  lambdaDofsRowIdx.resize(3);
63  // lambda_dofs_row_ents.resize(3);
64  lambdaDofsColIdx.resize(3);
65  // dofs indices for rows and columns
66  dispDofsRowIdx.resize(9);
67  dispDofsColIdx.resize(9);
68  localDispDofsRowIdx.resize(9);
69  // face node coordinates
70  coords.resize(9);
71  }

◆ ~ConstrainConstantAarea()

virtual ObosleteUsersModules::ConstrainConstantAarea::~ConstrainConstantAarea ( )
virtualdefault

Member Function Documentation

◆ calcDirevatives()

PetscErrorCode ObosleteUsersModules::ConstrainConstantAarea::calcDirevatives ( double diffNTRI,
double dofs_X,
double dofs_iX,
double C,
double iC,
double T,
double iT 
)
inline

calculate direvatives

Definition at line 245 of file ComplexConstArea.hpp.

247  {
249  double diffX_xi[3], diffX_eta[3];
250  bzero(diffX_xi, 3 * sizeof(double));
251  bzero(diffX_eta, 3 * sizeof(double));
252  double i_diffX_xi[3], i_diffX_eta[3];
253  bzero(i_diffX_xi, 3 * sizeof(double));
254  bzero(i_diffX_eta, 3 * sizeof(double));
255  Range adj_side_elems;
256 
257  BitRefLevel bit = problemPtr->getBitRefLevel();
258  if (!nInTheLoop) {
259  problemTets.clear();
260  CHKERR mField.getInterface<BitRefManager>()->getEntitiesByTypeAndRefLevel(
261  bit, BitRefLevel().set(), MBTET, problemTets);
262  }
263 
264  CHKERR mField.getInterface<BitRefManager>()->getAdjacencies(
265  bit, &face, 1, 3, adj_side_elems);
266  adj_side_elems = intersect(problemTets, adj_side_elems);
267  // adj_side_elems = adj_side_elems.subset_by_type(MBTET);
268  if (adj_side_elems.size() == 0) {
269  Range adj_tets_on_surface;
270  BitRefLevel bit_tet_on_surface;
271  bit_tet_on_surface.set(BITREFLEVEL_SIZE - 2);
272  CHKERR mField.getInterface<BitRefManager>()->getAdjacencies(
273  bit_tet_on_surface, &face, 1, 3, adj_tets_on_surface,
274  moab::Interface::INTERSECT, 0);
275 
276  adj_side_elems.insert(*adj_tets_on_surface.begin());
277  }
278  if (adj_side_elems.size() != 1) {
279  adj_side_elems.clear();
280  CHKERR mField.getInterface<BitRefManager>()->getAdjacencies(
281  bit, &face, 1, 3, adj_side_elems, moab::Interface::INTERSECT, 5);
282 
283  Range::iterator it = adj_side_elems.begin();
284  for (; it != adj_side_elems.end(); it++) {
285  Range nodes;
286  CHKERR mField.get_moab().get_connectivity(&*it, 1, nodes, true);
287  PetscPrintf(PETSC_COMM_WORLD, "%lu %lu %lu %lu\n", nodes[0], nodes[1],
288  nodes[2], nodes[3]);
289  }
290  ParallelComm *pcomm =
291  ParallelComm::get_pcomm(&mField.get_moab(), MYPCOMM_INDEX);
292  if (pcomm->rank() == 0) {
293  EntityHandle out_meshset;
294  CHKERR mField.get_moab().create_meshset(MESHSET_SET, out_meshset);
295  CHKERR mField.get_moab().add_entities(out_meshset, adj_side_elems);
296  CHKERR mField.get_moab().add_entities(out_meshset, &face, 1);
297  CHKERR mField.get_moab().write_file("debug_error.vtk", "VTK", "",
298  &out_meshset, 1);
299  CHKERR mField.get_moab().delete_entities(&out_meshset, 1);
300  }
301  SETERRQ1(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
302  "expect 1 tet but is %u", adj_side_elems.size());
303  }
304  EntityHandle side_elem = *adj_side_elems.begin();
305  int order[] = {0, 1, 2};
306  if (side_elem != 0) {
307  int side_number, sense, offset;
308  CHKERR moab.side_number(side_elem, face, side_number, sense, offset);
309  if (sense == -1) {
310  order[0] = 1;
311  order[1] = 0;
312  }
313  }
314  // calculate tangent vectors
315  // those vectors are in plane of face
316  for (int nn = 0; nn < 3; nn++) {
317  diffX_xi[0] +=
318  dofs_X[3 * order[nn] + 0] * diffNTRI[2 * nn + 0]; // unit [ m ]
319  diffX_xi[1] += dofs_X[3 * order[nn] + 1] * diffNTRI[2 * nn + 0];
320  diffX_xi[2] += dofs_X[3 * order[nn] + 2] * diffNTRI[2 * nn + 0];
321  diffX_eta[0] += dofs_X[3 * order[nn] + 0] * diffNTRI[2 * nn + 1];
322  diffX_eta[1] += dofs_X[3 * order[nn] + 1] * diffNTRI[2 * nn + 1];
323  diffX_eta[2] += dofs_X[3 * order[nn] + 2] * diffNTRI[2 * nn + 1];
324  if (dofs_iX == NULL)
325  continue;
326  i_diffX_xi[0] += dofs_iX[3 * order[nn] + 0] * diffNTRI[2 * nn + 0];
327  i_diffX_xi[1] += dofs_iX[3 * order[nn] + 1] * diffNTRI[2 * nn + 0];
328  i_diffX_xi[2] += dofs_iX[3 * order[nn] + 2] * diffNTRI[2 * nn + 0];
329  i_diffX_eta[0] += dofs_iX[3 * order[nn] + 0] * diffNTRI[2 * nn + 1];
330  i_diffX_eta[1] += dofs_iX[3 * order[nn] + 1] * diffNTRI[2 * nn + 1];
331  i_diffX_eta[2] += dofs_iX[3 * order[nn] + 2] * diffNTRI[2 * nn + 1];
332  }
333  // spins
334  double SpinX_xi[9], SpinX_eta[9];
335  CHKERR Spin(SpinX_xi, diffX_xi);
336  CHKERR Spin(SpinX_eta, diffX_eta);
337  double iSpinX_xi[9], iSpinX_eta[9];
338  CHKERR Spin(iSpinX_xi, i_diffX_xi);
339  CHKERR Spin(iSpinX_eta, i_diffX_eta);
340  __CLPK_doublecomplex xSpinX_xi[9], xSpinX_eta[9];
341  CHKERR make_complex_matrix(SpinX_xi, iSpinX_xi, xSpinX_xi); // unit [ m ]
342  CHKERR make_complex_matrix(SpinX_eta, iSpinX_eta, xSpinX_eta); // unit [ m ]
343  // calculate complex face normal vector
344  __CLPK_doublecomplex x_one = {1, 0};
345  __CLPK_doublecomplex x_zero = {0, 0};
346  __CLPK_doublecomplex x_normal[3];
347  __CLPK_doublecomplex x_diffX_eta[3];
348  x_diffX_eta[0].r = diffX_eta[0];
349  x_diffX_eta[0].i = i_diffX_eta[0];
350  x_diffX_eta[1].r = diffX_eta[1];
351  x_diffX_eta[1].i = i_diffX_eta[1];
352  x_diffX_eta[2].r = diffX_eta[2];
353  x_diffX_eta[2].i = i_diffX_eta[2];
354  cblas_zgemv(CblasRowMajor, CblasNoTrans, 3, 3, &x_one, xSpinX_xi, 3,
355  x_diffX_eta, 1, &x_zero, x_normal, 1); // unit [ m^2 ]
356  /*//debug
357  Tag th_normal1,th_normal2;
358  double def_NORMAL[] = {0, 0, 0};
359  CHKERR
360  moab.tag_get_handle("NORMAL1",3,MB_TYPE_DOUBLE,th_normal1,MB_TAG_CREAT|MB_TAG_SPARSE,def_NORMAL);
361  CHKERR
362  moab.tag_get_handle("NORMAL2",3,MB_TYPE_DOUBLE,th_normal2,MB_TAG_CREAT|MB_TAG_SPARSE,def_NORMAL);
363  double normal1[3] = { x_normal[0].r, x_normal[1].r, x_normal[2].r };
364  double normal2[3];
365  CHKERR ShapeFaceNormalMBTRI(&diffNTRI[0],&*coords.data().begin(),normal2);
366  if(side_elem!=0) {
367  int side_number,sense,offset;
368  CHKERR moab.side_number(side_elem,face,side_number,sense,offset);
369  if(sense == -1) {
370  cblas_dscal(3,-1,normal2,1);
371  }
372  }
373  double normal1_nrm2 = cblas_dnrm2(3,normal1,1);
374  cblas_dscal(3,1./normal1_nrm2,normal1,1);
375  double normal2_nrm2 = cblas_dnrm2(3,normal2,1);
376  cblas_dscal(3,1./normal2_nrm2,normal2,1);
377  CHKERR moab.tag_set_data(th_normal1,&face,1,normal1);
378  CHKERR moab.tag_set_data(th_normal2,&face,1,normal2); */
379  // calculate complex normal length
380  // double __complex__ x_nrm2 = csqrt(
381  // cpow((x_normal[0].r+I*x_normal[0].i),2+I*0)+
382  // cpow((x_normal[1].r+I*x_normal[1].i),2+I*0)+
383  // cpow((x_normal[2].r+I*x_normal[2].i),2+I*0)
384  // );
385  complex<double> x_nrm2;
386  x_nrm2 = sqrt(pow(complex<double>(x_normal[0].r, x_normal[0].i), 2) +
387  pow(complex<double>(x_normal[1].r, x_normal[1].i), 2) +
388  pow(complex<double>(x_normal[2].r, x_normal[2].i), 2));
389  // calculate dA/dX
390  __CLPK_doublecomplex xNSpinX_xi[3], xNSpinX_eta[3];
391  bzero(xNSpinX_xi, 3 * sizeof(__CLPK_doublecomplex));
392  bzero(xNSpinX_eta, 3 * sizeof(__CLPK_doublecomplex));
393  // __CLPK_doublecomplex x_scalar = { -creal(1./x_nrm2), -cimag(1./x_nrm2) };
394  // // unit [ 1/m^2 ]
395  __CLPK_doublecomplex x_scalar = {-real(1. / x_nrm2),
396  -imag(1. / x_nrm2)}; // unit [ 1/m^2 ]
397  cblas_zgemv(CblasRowMajor, CblasNoTrans, 3, 3, &x_scalar, xSpinX_xi, 3,
398  x_normal, 1, &x_zero, xNSpinX_xi,
399  1); // unit [ 1/m^2 * m = 1/m ]
400  cblas_zgemv(CblasRowMajor, CblasNoTrans, 3, 3, &x_scalar, xSpinX_eta, 3,
401  x_normal, 1, &x_zero, xNSpinX_eta,
402  1); // unit [ 1/m^2 * m = 1/m ]
403  if (C != NULL)
404  bzero(C, 9 * sizeof(double));
405  if (iC != NULL)
406  bzero(iC, 9 * sizeof(double));
407  if (T != NULL)
408  bzero(T, 9 * sizeof(double));
409  if (iT != NULL)
410  bzero(iT, 9 * sizeof(double));
411  for (int nn = 0; nn < 3; nn++) {
412  double A[3], iA[3];
413  A[0] = xNSpinX_xi[0].r * diffNTRI[2 * order[nn] + 1] -
414  xNSpinX_eta[0].r * diffNTRI[2 * order[nn] + 0]; // unit [ 1/m ]
415  A[1] = xNSpinX_xi[1].r * diffNTRI[2 * order[nn] + 1] -
416  xNSpinX_eta[1].r * diffNTRI[2 * order[nn] + 0];
417  A[2] = xNSpinX_xi[2].r * diffNTRI[2 * order[nn] + 1] -
418  xNSpinX_eta[2].r * diffNTRI[2 * order[nn] + 0];
419  iA[0] = xNSpinX_xi[0].i * diffNTRI[2 * order[nn] + 1] -
420  xNSpinX_eta[0].i * diffNTRI[2 * order[nn] + 0]; // unit [ 1/m ]
421  iA[1] = xNSpinX_xi[1].i * diffNTRI[2 * order[nn] + 1] -
422  xNSpinX_eta[1].i * diffNTRI[2 * order[nn] + 0];
423  iA[2] = xNSpinX_xi[2].i * diffNTRI[2 * order[nn] + 1] -
424  xNSpinX_eta[2].i * diffNTRI[2 * order[nn] + 0];
425  if (C != NULL) {
426  C[3 * nn + 0] = A[0];
427  C[3 * nn + 1] = A[1];
428  C[3 * nn + 2] = A[2];
429  }
430  if (iC != NULL) {
431  iC[3 * nn + 0] = iA[0];
432  iC[3 * nn + 1] = iA[1];
433  iC[3 * nn + 2] = iA[2];
434  }
435  if ((T != NULL) || (iT != NULL)) {
436  double SpinA[9];
437  CHKERR Spin(SpinA, A); // unit [1/m]
438  double iSpinA[9];
439  CHKERR Spin(iSpinA, iA); // unit [1/m]
440  __CLPK_doublecomplex xSpinA[9];
441  // make spin matrix to calculate cross product
442  CHKERR make_complex_matrix(SpinA, iSpinA, xSpinA);
443  __CLPK_doublecomplex xT[3];
444  cblas_zgemv(CblasRowMajor, CblasNoTrans, 3, 3, &x_scalar, xSpinA, 3,
445  x_normal, 1, &x_zero, xT, 1); // unit [1/m]
446  if (T != NULL) {
447  T[3 * nn + 0] = xT[0].r;
448  T[3 * nn + 1] = xT[1].r;
449  T[3 * nn + 2] = xT[2].r;
450  }
451  if (iT != NULL) {
452  iT[3 * nn + 0] = xT[0].i;
453  iT[3 * nn + 1] = xT[1].i;
454  iT[3 * nn + 2] = xT[2].i;
455  }
456  }
457  }
458  if (C != NULL)
459  cblas_dscal(9, 0.25, C, 1);
460  if (iC != NULL)
461  cblas_dscal(9, 0.25, iC, 1);
462  if (T != NULL)
463  cblas_dscal(9, 0.25, T, 1);
464  if (iT != NULL)
465  cblas_dscal(9, 0.25, iT, 1);
467  }

◆ getData()

PetscErrorCode ObosleteUsersModules::ConstrainConstantAarea::getData ( bool  is_that_C_otherwise_dC,
bool  trans 
)
inline

get face data, indices and coors and nodal values

Parameters
is_that_C_otherwise_dC

Definition at line 105 of file ComplexConstArea.hpp.

105  {
107 
108  face = numeredEntFiniteElementPtr->getEnt();
109  fill(lambdaDofsRowIdx.begin(), lambdaDofsRowIdx.end(), -1);
110  fill(lambdaDofsColIdx.begin(), lambdaDofsColIdx.end(), -1);
111  fill(dispDofsRowIdx.begin(), dispDofsRowIdx.end(), -1);
112  fill(dispDofsColIdx.begin(), dispDofsColIdx.end(), -1);
113  fill(localDispDofsRowIdx.begin(), localDispDofsRowIdx.end(), -1);
114  fill(lambda.begin(), lambda.end(), 0);
115  // fill(lambda_dofs_row_ents.begin(),lambda_dofs_row_ents.end(),no_handle);
116  const EntityHandle *conn_face;
117  int num_nodes;
118  CHKERR moab.get_connectivity(face, conn_face, num_nodes, true);
119  if (num_nodes != 3)
120  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
121  "face should have three nodes");
122  CHKERR moab.get_coords(conn_face, num_nodes, &*coords.data().begin());
123 
124  const auto field_bit_number = mField.get_field_bit_number(lambdaFieldName);
125  const auto pos_bit_number =
126  mField.get_field_bit_number("MESH_NODE_POSITIONS");
127 
128  auto row_dofs = getRowDofsPtr();
129 
130  for (int nn = 0; nn < num_nodes; nn++) {
131 
132  if (is_that_C_otherwise_dC) {
133 
134  auto dit = loIt(row_dofs, field_bit_number, conn_face[nn]);
135  auto hi_dit = hiIt(row_dofs, field_bit_number, conn_face[nn]);
136 
137  // it is C
138  // get rows which are Lagrange multipliers
139  if (std::distance(dit, hi_dit) > 0) {
140  if (std::distance(dit, hi_dit) != 1) {
141  SETERRQ1(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
142  "data inconsistency, number of dof on node for < %s > "
143  "should be 1",
144  lambdaFieldName.c_str());
145  }
146  if (dit->get()->getPetscLocalDofIdx() < 0) {
147  SETERRQ(
148  PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
149  "data inconsistency, negative index of local dofs on element");
150  }
151  lambda[nn] = dit->get()->getFieldData();
152  lambdaDofsRowIdx[nn] = dit->get()->getPetscGlobalDofIdx();
153  // lambda_dofs_row_ents[nn] = dit->getEnt();
154  }
155  }
156  if ((!is_that_C_otherwise_dC) || (trans)) {
157 
158  auto dit = loIt(row_dofs, field_bit_number, conn_face[nn]);
159  auto hi_dit = hiIt(row_dofs, field_bit_number, conn_face[nn]);
160 
161  // it is dC
162  // get rows which are material nodal positions
163  if (std::distance(dit, hi_dit) > 0) {
164  if (std::distance(dit, hi_dit) != 1)
165  SETERRQ1(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
166  "data inconsistency, number of dof on node for < %s > "
167  "should be 1",
168  lambdaFieldName.c_str());
169  lambda[nn] = dit->get()->getFieldData();
170 
171  auto diit = loIt(row_dofs, pos_bit_number, conn_face[nn]);
172  auto hi_diit = hiIt(row_dofs, pos_bit_number, conn_face[nn]);
173 
174  if (std::distance(diit, hi_diit) != 3)
175  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
176  "data inconsistency, number of dof on node for "
177  "MESH_NODE_POSITIONS should be 3");
178  for (; diit != hi_diit; diit++) {
179  if (diit->get()->getPetscLocalDofIdx() < 0)
180  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
181  "data inconsistency, negative index of local dofs on "
182  "element");
183  assert(nn * 3 + diit->get()->getDofCoeffIdx() < 9);
184  dispDofsRowIdx[nn * 3 + diit->get()->getDofCoeffIdx()] =
185  diit->get()->getPetscGlobalDofIdx();
186  localDispDofsRowIdx[nn * 3 + diit->get()->getDofCoeffIdx()] =
187  diit->get()->getPetscLocalDofIdx();
188  }
189  }
190  }
191 
192 
193  auto col_dofs = getColDofsPtr();
194 
195  // get columns which are material nodal positions
196  auto dit = loIt(col_dofs, pos_bit_number, conn_face[nn]);
197  auto hi_dit = hiIt(col_dofs, pos_bit_number, conn_face[nn]);
198  if (std::distance(dit, hi_dit) != 3) {
199  SETERRQ1(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
200  "data inconsistency, number of dof on node for "
201  "MESH_NODE_POSITIONS should be 3, nb dofs = %d",
202  std::distance(dit, hi_dit));
203  }
204  for (; dit != hi_dit; dit++) {
205  if (dit->get()->getPetscLocalDofIdx() < 0) {
206  SETERRQ(
207  PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
208  "data inconsistency, negative index of local dofs on element");
209  }
210  dofs_X[nn * 3 + dit->get()->getDofCoeffIdx()] =
211  dit->get()->getFieldData();
212  assert(nn * 3 + dit->get()->getDofCoeffIdx() < 9);
213  dispDofsColIdx[nn * 3 + dit->get()->getDofCoeffIdx()] =
214  dit->get()->getPetscGlobalDofIdx();
215  }
216 
217  if (trans) {
218  auto dit = loIt(col_dofs, field_bit_number, conn_face[nn]);
219  auto hi_dit = hiIt(col_dofs, field_bit_number, conn_face[nn]);
220  if (std::distance(dit, hi_dit) > 0) {
221  if (std::distance(dit, hi_dit) != 1) {
222  SETERRQ1(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
223  "data inconsistency, number of dof on node for < %s > "
224  "should be 1",
225  lambdaFieldName.c_str());
226  }
227  if (dit->get()->getPetscLocalDofIdx() < 0) {
228  SETERRQ(
229  PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
230  "data inconsistency, negative index of local dofs on element");
231  }
232  lambdaDofsColIdx[nn] = dit->get()->getPetscGlobalDofIdx();
233  }
234  }
235  }
237  }

◆ hiIt()

template<typename DOFS >
auto ObosleteUsersModules::ConstrainConstantAarea::hiIt ( DOFS  dofs,
const FieldBitNumber  bit,
const EntityHandle  ent 
)
inline

Definition at line 95 of file ComplexConstArea.hpp.

96  {
97  return dofs->upper_bound(DofEntity::getHiFieldEntityUId(bit, ent));
98  };

◆ loIt()

template<typename DOFS >
auto ObosleteUsersModules::ConstrainConstantAarea::loIt ( DOFS  dofs,
const FieldBitNumber  bit,
const EntityHandle  ent 
)
inline

Definition at line 89 of file ComplexConstArea.hpp.

90  {
91  return dofs->lower_bound(DofEntity::getLoFieldEntityUId(bit, ent));
92  };

◆ operator()()

PetscErrorCode ObosleteUsersModules::ConstrainConstantAarea::operator() ( )
inline

Definition at line 487 of file ComplexConstArea.hpp.

487  {
489 
490  CHKERR getData(true, false);
491 
492  ublas::vector<double, ublas::bounded_array<double, 9>> ELEM_CONSTRAIN(9);
493  CHKERR calcDirevatives(&*diffNTRI.data().begin(), &*dofs_X.data().begin(),
494  NULL, &*ELEM_CONSTRAIN.data().begin(), NULL, NULL,
495  NULL);
496  for (int nn = 0; nn < 3; nn++) {
497  if (lambdaDofsRowIdx[nn] == -1)
498  continue;
499  for (int NN = 0; NN < 3; NN++) {
500  if (NN != nn)
501  continue;
502  if (Q == PETSC_NULL) {
503  CHKERR MatSetValues(C, 1, &(lambdaDofsRowIdx.data()[nn]), 3,
504  &(dispDofsColIdx.data()[3 * NN]),
505  &ELEM_CONSTRAIN.data()[3 * NN], ADD_VALUES);
506  }
507  if (Q != PETSC_NULL) {
508  if (mapV.find(lambdaDofsRowIdx[nn]) == mapV.end())
509  SETERRQ(PETSC_COMM_SELF, 1, "data inconsistency");
511  &(dispDofsColIdx.data()[3 * NN]),
512  &ELEM_CONSTRAIN.data()[3 * NN], ADD_VALUES);
513  }
514  }
515  }
516 
518  }

◆ postProcess()

PetscErrorCode ObosleteUsersModules::ConstrainConstantAarea::postProcess ( )
inline

Definition at line 520 of file ComplexConstArea.hpp.

520  {
522  if (Q != PETSC_NULL) {
523  ParallelComm *pcomm = ParallelComm::get_pcomm(&moab, MYPCOMM_INDEX);
524  Vec Qv;
525  CHKERR mField.getInterface<VecManager>()->vecCreateGhost(
526  problemPtr->getName(), COL, &Qv);
527  const auto field_bit_number =
530  field_bit_number, dofs)) {
531  if (mapV.find(dofs->get()->getPetscGlobalDofIdx()) == mapV.end()) {
532  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
533  "data inconsistency");
534  }
535  CHKERR VecAssemblyBegin(mapV[dofs->get()->getPetscGlobalDofIdx()]);
536  CHKERR VecAssemblyEnd(mapV[dofs->get()->getPetscGlobalDofIdx()]);
537  CHKERR MatMult(Q, mapV[dofs->get()->getPetscGlobalDofIdx()], Qv);
538  CHKERR VecGhostUpdateBegin(Qv, INSERT_VALUES, SCATTER_FORWARD);
539  CHKERR VecGhostUpdateEnd(Qv, INSERT_VALUES, SCATTER_FORWARD);
540  double *array;
541  CHKERR VecGetArray(Qv, &array);
542  vector<DofIdx> glob_idx;
543  vector<double> vals;
544  for (_IT_NUMEREDDOF_COL_BY_ENT_FOR_LOOP_(problemPtr,
545  dofs->get()->getEnt(), diit)) {
546  if (diit->get()->getPart() != pcomm->rank())
547  continue;
548  if (diit->get()->getName() != "MESH_NODE_POSITIONS")
549  continue;
550  glob_idx.push_back(diit->get()->getPetscGlobalDofIdx());
551  if (diit->get()->getPetscLocalDofIdx() < 0) {
552  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
553  "data inconsistency");
554  }
555  vals.push_back(array[diit->get()->getPetscLocalDofIdx()]);
556  }
557  int row = dofs->get()->getPetscGlobalDofIdx();
558  CHKERR MatSetValues(C, 1, &row, glob_idx.size(),
559  glob_idx.empty() ? PETSC_NULL : &glob_idx[0],
560  vals.empty() ? PETSC_NULL : &vals[0], ADD_VALUES);
561  CHKERR VecRestoreArray(Qv, &array);
562  CHKERR VecDestroy(&mapV[dofs->get()->getPetscGlobalDofIdx()]);
563  }
564  CHKERR VecDestroy(&Qv);
565  mapV.clear();
566  }
568  }

◆ preProcess()

PetscErrorCode ObosleteUsersModules::ConstrainConstantAarea::preProcess ( )
inline

Definition at line 470 of file ComplexConstArea.hpp.

470  {
472 
473  if (Q != PETSC_NULL) {
474  const auto field_bit_number =
477  problemPtr, field_bit_number, dofs_it)) {
478  CHKERR MatCreateVecs(C, &mapV[dofs_it->get()->getPetscGlobalDofIdx()],
479  PETSC_NULL);
480  CHKERR VecZeroEntries(mapV[dofs_it->get()->getPetscGlobalDofIdx()]);
481  }
482  }
483 
485  }

Member Data Documentation

◆ C

Mat ObosleteUsersModules::ConstrainConstantAarea::C

Definition at line 43 of file ComplexConstArea.hpp.

◆ coords

ublas::vector<double, ublas::bounded_array<double, 9> > ObosleteUsersModules::ConstrainConstantAarea::coords

Definition at line 82 of file ComplexConstArea.hpp.

◆ diffNTRI

MatrixDouble ObosleteUsersModules::ConstrainConstantAarea::diffNTRI

Definition at line 76 of file ComplexConstArea.hpp.

◆ DirichletBC

vector<DofIdx> ObosleteUsersModules::ConstrainConstantAarea::DirichletBC

Definition at line 78 of file ComplexConstArea.hpp.

◆ dispDofsColIdx

VectorInt ObosleteUsersModules::ConstrainConstantAarea::dispDofsColIdx

Definition at line 79 of file ComplexConstArea.hpp.

◆ dispDofsRowIdx

VectorInt ObosleteUsersModules::ConstrainConstantAarea::dispDofsRowIdx

Definition at line 79 of file ComplexConstArea.hpp.

◆ dofs_X

ublas::vector<double, ublas::bounded_array<double, 9> > ObosleteUsersModules::ConstrainConstantAarea::dofs_X

Definition at line 83 of file ComplexConstArea.hpp.

◆ face

EntityHandle ObosleteUsersModules::ConstrainConstantAarea::face

Definition at line 86 of file ComplexConstArea.hpp.

◆ G_TRI_W

const double* ObosleteUsersModules::ConstrainConstantAarea::G_TRI_W

Definition at line 77 of file ComplexConstArea.hpp.

◆ lambda

ublas::vector<double, ublas::bounded_array<double, 3> > ObosleteUsersModules::ConstrainConstantAarea::lambda

Definition at line 84 of file ComplexConstArea.hpp.

◆ lambdaDofsColIdx

VectorInt ObosleteUsersModules::ConstrainConstantAarea::lambdaDofsColIdx

Definition at line 81 of file ComplexConstArea.hpp.

◆ lambdaDofsRowIdx

VectorInt ObosleteUsersModules::ConstrainConstantAarea::lambdaDofsRowIdx

Definition at line 81 of file ComplexConstArea.hpp.

◆ lambdaFieldName

string ObosleteUsersModules::ConstrainConstantAarea::lambdaFieldName

Definition at line 45 of file ComplexConstArea.hpp.

◆ localDispDofsRowIdx

VectorInt ObosleteUsersModules::ConstrainConstantAarea::localDispDofsRowIdx

Definition at line 80 of file ComplexConstArea.hpp.

◆ mapV

map<DofIdx, Vec> ObosleteUsersModules::ConstrainConstantAarea::mapV

Definition at line 469 of file ComplexConstArea.hpp.

◆ mField

MoFEM::Interface& ObosleteUsersModules::ConstrainConstantAarea::mField

Definition at line 39 of file ComplexConstArea.hpp.

◆ moab

moab::Interface& ObosleteUsersModules::ConstrainConstantAarea::moab

Definition at line 41 of file ComplexConstArea.hpp.

◆ problemTets

Range ObosleteUsersModules::ConstrainConstantAarea::problemTets

Definition at line 239 of file ComplexConstArea.hpp.

◆ Q

Mat ObosleteUsersModules::ConstrainConstantAarea::Q

Definition at line 44 of file ComplexConstArea.hpp.

◆ verbose

int ObosleteUsersModules::ConstrainConstantAarea::verbose

Definition at line 46 of file ComplexConstArea.hpp.


The documentation for this struct was generated from the following file:
MoFEM::UnknownInterface::getInterface
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.
Definition: UnknownInterface.hpp:93
ObosleteUsersModules::ConstrainConstantAarea::dofs_X
ublas::vector< double, ublas::bounded_array< double, 9 > > dofs_X
Definition: ComplexConstArea.hpp:83
MYPCOMM_INDEX
#define MYPCOMM_INDEX
default communicator number PCOMM
Definition: definitions.h:228
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:1644
EntityHandle
ObosleteUsersModules::ConstrainConstantAarea::verbose
int verbose
Definition: ComplexConstArea.hpp:46
ObosleteUsersModules::ConstrainConstantAarea::mField
MoFEM::Interface & mField
Definition: ComplexConstArea.hpp:39
ObosleteUsersModules::ConstrainConstantAarea::problemTets
Range problemTets
Definition: ComplexConstArea.hpp:239
ObosleteUsersModules::ConstrainConstantAarea::hiIt
auto hiIt(DOFS dofs, const FieldBitNumber bit, const EntityHandle ent)
Definition: ComplexConstArea.hpp:95
__CLPK_doublecomplex::r
__CLPK_doublereal r
Definition: lapack_wrap.h:35
MoFEM::CoreInterface::get_field_bit_number
virtual FieldBitNumber get_field_bit_number(const std::string name) const =0
get field bit number
ObosleteUsersModules::ConstrainConstantAarea::C
Mat C
Definition: ComplexConstArea.hpp:43
A
constexpr AssemblyType A
Definition: operators_tests.cpp:30
ObosleteUsersModules::ConstrainConstantAarea::dispDofsRowIdx
VectorInt dispDofsRowIdx
Definition: ComplexConstArea.hpp:79
MoFEM::VecSetValues
MoFEMErrorCode VecSetValues(Vec V, const EntitiesFieldData::EntData &data, const double *ptr, InsertMode iora)
Assemble PETSc vector.
Definition: EntitiesFieldData.hpp:1589
sdf.r
int r
Definition: sdf.py:8
_IT_NUMEREDDOF_COL_BY_ENT_FOR_LOOP_
#define _IT_NUMEREDDOF_COL_BY_ENT_FOR_LOOP_(PROBLEMPTR, ENT, IT)
use with loops to iterate col DOFs
Definition: ProblemsMultiIndices.hpp:297
order
constexpr int order
Definition: dg_projection.cpp:18
ObosleteUsersModules::ConstrainConstantAarea::G_TRI_W
const double * G_TRI_W
Definition: ComplexConstArea.hpp:77
ShapeDiffMBTRI
PetscErrorCode ShapeDiffMBTRI(double *diffN)
calculate derivatives of shape functions
Definition: fem_tools.c:194
CHKERR
#define CHKERR
Inline error check.
Definition: definitions.h:548
MoFEM::CoreInterface::get_moab
virtual moab::Interface & get_moab()=0
ObosleteUsersModules::ConstrainConstantAarea::lambda
ublas::vector< double, ublas::bounded_array< double, 3 > > lambda
Definition: ComplexConstArea.hpp:84
_IT_NUMEREDDOF_ROW_BY_BITNUMBER_FOR_LOOP_
#define _IT_NUMEREDDOF_ROW_BY_BITNUMBER_FOR_LOOP_(PROBLEMPTR, FIELD_BIT_NUMBER, IT)
Definition: ProblemsMultiIndices.hpp:338
ObosleteUsersModules::ConstrainConstantAarea::localDispDofsRowIdx
VectorInt localDispDofsRowIdx
Definition: ComplexConstArea.hpp:80
Spin
PetscErrorCode Spin(double *spinOmega, double *vecOmega)
calculate spin matrix from vector
Definition: fem_tools.c:546
bit
auto bit
set bit
Definition: hanging_node_approx.cpp:75
ObosleteUsersModules::ConstrainConstantAarea::dispDofsColIdx
VectorInt dispDofsColIdx
Definition: ComplexConstArea.hpp:79
COL
@ COL
Definition: definitions.h:136
ObosleteUsersModules::ConstrainConstantAarea::diffNTRI
MatrixDouble diffNTRI
Definition: ComplexConstArea.hpp:76
make_complex_matrix
PetscErrorCode make_complex_matrix(double *reA, double *imA, __CLPK_doublecomplex *xA)
Compose complex matrix (3x3) from two real matrices.
Definition: fem_tools.c:557
ObosleteUsersModules::ConstrainConstantAarea::getData
PetscErrorCode getData(bool is_that_C_otherwise_dC, bool trans)
get face data, indices and coors and nodal values
Definition: ComplexConstArea.hpp:105
ObosleteUsersModules::ConstrainConstantAarea::face
EntityHandle face
Definition: ComplexConstArea.hpp:86
ObosleteUsersModules::ConstrainConstantAarea::calcDirevatives
PetscErrorCode calcDirevatives(double *diffNTRI, double *dofs_X, double *dofs_iX, double *C, double *iC, double *T, double *iT)
calculate direvatives
Definition: ComplexConstArea.hpp:245
i
FTensor::Index< 'i', SPACE_DIM > i
Definition: hcurl_divergence_operator_2d.cpp:27
ObosleteUsersModules::ConstrainConstantAarea::mapV
map< DofIdx, Vec > mapV
Definition: ComplexConstArea.hpp:469
ObosleteUsersModules::ConstrainConstantAarea::lambdaDofsRowIdx
VectorInt lambdaDofsRowIdx
Definition: ComplexConstArea.hpp:81
Range
ObosleteUsersModules::ConstrainConstantAarea::loIt
auto loIt(DOFS dofs, const FieldBitNumber bit, const EntityHandle ent)
Definition: ComplexConstArea.hpp:89
G_TRI_W1
static const double G_TRI_W1[]
Definition: fem_tools.h:314
ObosleteUsersModules::ConstrainConstantAarea::lambdaFieldName
string lambdaFieldName
Definition: ComplexConstArea.hpp:45
BITREFLEVEL_SIZE
#define BITREFLEVEL_SIZE
max number of refinements
Definition: definitions.h:232
ObosleteUsersModules::ConstrainConstantAarea::moab
moab::Interface & moab
Definition: ComplexConstArea.hpp:41
ObosleteUsersModules::ConstrainConstantAarea::lambdaDofsColIdx
VectorInt lambdaDofsColIdx
Definition: ComplexConstArea.hpp:81
ObosleteUsersModules::ConstrainConstantAarea::Q
Mat Q
Definition: ComplexConstArea.hpp:44
EigenMatrix::Vec
const FTensor::Tensor2< T, Dim, Dim > Vec
Definition: MatrixFunction.hpp:66
MOFEM_DATA_INCONSISTENCY
@ MOFEM_DATA_INCONSISTENCY
Definition: definitions.h:31
MoFEM::Types::BitRefLevel
std::bitset< BITREFLEVEL_SIZE > BitRefLevel
Bit structure attached to each entity identifying to what mesh entity is attached.
Definition: Types.hpp:40
__CLPK_doublecomplex::i
__CLPK_doublereal i
Definition: lapack_wrap.h:35
MoFEMFunctionReturn
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:429
__CLPK_doublecomplex
Definition: lapack_wrap.h:34
ObosleteUsersModules::ConstrainConstantAarea::coords
ublas::vector< double, ublas::bounded_array< double, 9 > > coords
Definition: ComplexConstArea.hpp:82
MoFEMFunctionBegin
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:359