v0.14.0
FlatPrismElementForcesAndSourcesCore.cpp
Go to the documentation of this file.
1 /** \file FlatPrismElementForcesAndSourcesCore.cpp
2 
3 \brief Implementation of flat prism element
4 
5 */
6 
7 
8 
9 namespace MoFEM {
10 
12  Interface &m_field)
13  : ForcesAndSourcesCore(m_field),
14  meshPositionsFieldName("MESH_NODE_POSITIONS"),
15  opHOCoordsAndNormals(hoCoordsAtGaussPtsF3, nOrmals_at_GaussPtF3,
16  tAngent1_at_GaussPtF3, tAngent2_at_GaussPtF3,
17  hoCoordsAtGaussPtsF4, nOrmals_at_GaussPtF4,
18  tAngent1_at_GaussPtF4, tAngent2_at_GaussPtF4) {
20  boost::shared_ptr<BaseFunction>(new FlatPrismPolynomialBase());
22  "Problem with creation data on element")
23 }
24 
27 
28  if (numeredEntFiniteElementPtr->getEntType() != MBPRISM)
30 
31  EntitiesFieldData &data_div = *dataOnElement[HDIV];
32  EntitiesFieldData &data_curl = *dataOnElement[HCURL];
34 
36  int num_nodes;
37  const EntityHandle *conn;
38  CHKERR mField.get_moab().get_connectivity(ent, conn, num_nodes, true);
39  {
40  coords.resize(num_nodes * 3, false);
41  CHKERR mField.get_moab().get_coords(conn, num_nodes,
42  &*coords.data().begin());
43 
44  double diff_n[6];
45  CHKERR ShapeDiffMBTRI(diff_n);
46  normal.resize(6, false);
47  CHKERR ShapeFaceNormalMBTRI(diff_n, &coords[0], &normal[0]);
48  CHKERR ShapeFaceNormalMBTRI(diff_n, &coords[9], &normal[3]);
49  aRea[0] = cblas_dnrm2(3, &normal[0], 1) * 0.5;
50  aRea[1] = cblas_dnrm2(3, &normal[3], 1) * 0.5;
51  }
52 
54 
55  // H1
56  if ((dataH1.spacesOnEntities[MBVERTEX]).test(H1)) {
57  CHKERR getEntitySense<MBEDGE>(dataH1);
58  CHKERR getEntityDataOrder<MBEDGE>(dataH1, H1);
59  CHKERR getEntitySense<MBTRI>(dataH1);
60  CHKERR getEntityDataOrder<MBTRI>(dataH1, H1);
61  }
62 
63  // H1
64  if ((dataH1.spacesOnEntities[MBEDGE]).test(HCURL)) {
65  CHKERR getEntitySense<MBEDGE>(data_curl);
66  CHKERR getEntityDataOrder<MBEDGE>(data_curl, HCURL);
67  CHKERR getEntitySense<MBTRI>(data_curl);
68  CHKERR getEntityDataOrder<MBTRI>(data_curl, HCURL);
69  }
70 
71  // Hdiv
72  if ((dataH1.spacesOnEntities[MBTRI]).test(HDIV)) {
73  CHKERR getEntitySense<MBTRI>(data_div);
74  CHKERR getEntityDataOrder<MBTRI>(data_div, HDIV);
75  }
76 
77  // L2
78  if ((dataH1.spacesOnEntities[MBTRI]).test(L2)) {
79  CHKERR getEntitySense<MBTRI>(data_l2);
80  CHKERR getEntityDataOrder<MBTRI>(data_l2, L2);
81  }
82 
83  int order_data = getMaxDataOrder();
84  int order_row = getMaxRowOrder();
85  int order_col = getMaxColOrder();
86  int rule = getRule(order_row, order_col, order_data);
87  int nb_gauss_pts;
88  // int rule = getRule(order);
89  if (rule >= 0) {
90  if (rule < QUAD_2D_TABLE_SIZE) {
91  if (QUAD_2D_TABLE[rule]->dim != 2) {
92  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY, "wrong dimension");
93  }
94  if (QUAD_2D_TABLE[rule]->order < rule) {
95  SETERRQ2(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
96  "wrong order %d != %d", QUAD_2D_TABLE[rule]->order, rule);
97  }
98  nb_gauss_pts = QUAD_2D_TABLE[rule]->npoints;
99  gaussPts.resize(3, nb_gauss_pts, false);
100  cblas_dcopy(nb_gauss_pts, &QUAD_2D_TABLE[rule]->points[1], 3,
101  &gaussPts(0, 0), 1);
102  cblas_dcopy(nb_gauss_pts, &QUAD_2D_TABLE[rule]->points[2], 3,
103  &gaussPts(1, 0), 1);
104  cblas_dcopy(nb_gauss_pts, QUAD_2D_TABLE[rule]->weights, 1,
105  &gaussPts(2, 0), 1);
106  dataH1.dataOnEntities[MBVERTEX][0].getN(NOBASE).resize(nb_gauss_pts, 3,
107  false);
108  double *shape_ptr =
109  &*dataH1.dataOnEntities[MBVERTEX][0].getN(NOBASE).data().begin();
110  cblas_dcopy(3 * nb_gauss_pts, QUAD_2D_TABLE[rule]->points, 1, shape_ptr,
111  1);
112  } else {
113  SETERRQ2(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
114  "rule > quadrature order %d < %d", rule, QUAD_2D_TABLE_SIZE);
115  nb_gauss_pts = 0;
116  }
117  } else {
118  CHKERR setGaussPts(order_row, order_col, order_data);
119  nb_gauss_pts = gaussPts.size2();
120  dataH1.dataOnEntities[MBVERTEX][0].getN(NOBASE).resize(nb_gauss_pts, 3,
121  false);
122  if (nb_gauss_pts) {
124  &*dataH1.dataOnEntities[MBVERTEX][0].getN(NOBASE).data().begin(),
125  &gaussPts(0, 0), &gaussPts(1, 0), nb_gauss_pts);
126  }
127  }
128 
129  if (nb_gauss_pts == 0)
131 
132  {
133  coordsAtGaussPts.resize(nb_gauss_pts, 6, false);
134  for (int gg = 0; gg < nb_gauss_pts; gg++) {
135  for (int dd = 0; dd < 3; dd++) {
136  coordsAtGaussPts(gg, dd) = cblas_ddot(
137  3, &dataH1.dataOnEntities[MBVERTEX][0].getN(NOBASE)(gg, 0), 1,
138  &coords[dd], 3);
139  coordsAtGaussPts(gg, 3 + dd) = cblas_ddot(
140  3, &dataH1.dataOnEntities[MBVERTEX][0].getN(NOBASE)(gg, 0), 1,
141  &coords[9 + dd], 3);
142  }
143  }
144  }
145 
146  for (int space = HCURL; space != LASTSPACE; ++space)
147  if (dataOnElement[space]) {
148  dataH1.dataOnEntities[MBVERTEX][0].getNSharedPtr(NOBASE) =
149  dataOnElement[H1]->dataOnEntities[MBVERTEX][0].getNSharedPtr(NOBASE);
150  }
151 
152  for (int b = AINSWORTH_LEGENDRE_BASE; b != LASTBASE; b++) {
153  if (dataH1.bAse.test(b)) {
154  switch (static_cast<FieldApproximationBase>(b)) {
157  if (dataH1.spacesOnEntities[MBVERTEX].test(H1)) {
158  CHKERR getElementPolynomialBase()->getValue(
159  gaussPts,
160  boost::shared_ptr<BaseFunctionCtx>(new FlatPrismPolynomialBaseCtx(
162  H1, static_cast<FieldApproximationBase>(b), NOBASE)));
163  }
164  #ifndef NDEBUG
165  if (dataH1.spacesOnEntities[MBTRI].test(HDIV)) {
166  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
167  "Not yet implemented");
168  }
169  if (dataH1.spacesOnEntities[MBEDGE].test(HCURL)) {
170  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
171  "Not yet implemented");
172  }
173  if (dataH1.spacesOnEntities[MBTET].test(L2)) {
174  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
175  "Not yet implemented");
176  }
177 #endif
178  break;
179  default:
180  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
181  "Not yet implemented");
182  }
183  }
184  }
185 
186  auto check_field = [&]() {
187  auto field_it =
189  if (field_it != fieldsPtr->get<FieldName_mi_tag>().end())
190  if ((numeredEntFiniteElementPtr->getBitFieldIdData() &
191  (*field_it)->getId())
192  .any())
193  return true;
194  return false;
195  };
196 
197  // Check if field meshPositionsFieldName exist
198  if (check_field()) {
199 
200  hoCoordsAtGaussPtsF3.resize(nb_gauss_pts, 3, false);
201  nOrmals_at_GaussPtF3.resize(nb_gauss_pts, 3, false);
202  tAngent1_at_GaussPtF3.resize(nb_gauss_pts, 3, false);
203  tAngent2_at_GaussPtF3.resize(nb_gauss_pts, 3, false);
204  hoCoordsAtGaussPtsF4.resize(nb_gauss_pts, 3, false);
205  nOrmals_at_GaussPtF4.resize(nb_gauss_pts, 3, false);
206  tAngent1_at_GaussPtF4.resize(nb_gauss_pts, 3, false);
207  tAngent2_at_GaussPtF4.resize(nb_gauss_pts, 3, false);
208  const auto bit_number = mField.get_field_bit_number(meshPositionsFieldName);
209  CHKERR getNodesFieldData(dataH1, bit_number);
210  CHKERR getEntityFieldData(dataH1, bit_number, MBEDGE);
211  CHKERR getEntityFieldData(dataH1, bit_number, MBEDGE);
214  } else {
215  hoCoordsAtGaussPtsF3.resize(0, 0, false);
216  nOrmals_at_GaussPtF3.resize(0, 0, false);
217  tAngent1_at_GaussPtF3.resize(0, 0, false);
218  tAngent2_at_GaussPtF3.resize(0, 0, false);
219  hoCoordsAtGaussPtsF4.resize(0, 0, false);
220  nOrmals_at_GaussPtF4.resize(0, 0, false);
221  tAngent1_at_GaussPtF4.resize(0, 0, false);
222  tAngent2_at_GaussPtF4.resize(0, 0, false);
223  }
224 
225 #ifndef NDEBUG
226  if (dataH1.spacesOnEntities[MBTRI].test(HDIV)) {
227  SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED, "not implemented yet");
228  }
229 #endif
230 
231  // Iterate over operators
233 
235 }
236 
238  ForcesAndSourcesCore *ptr) {
240  if (!(ptrFE = dynamic_cast<FlatPrismElementForcesAndSourcesCore *>(ptr)))
241  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
242  "User operator and finite element do not work together");
244 }
245 
246 } // namespace MoFEM
MoFEMFunctionReturnHot
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:447
H1
@ H1
continuous field
Definition: definitions.h:85
MoFEM::DataOperator::opRhs
virtual MoFEMErrorCode opRhs(EntitiesFieldData &data, const bool error_if_no_base=false)
Definition: DataOperators.cpp:140
LASTBASE
@ LASTBASE
Definition: definitions.h:69
MoFEM::ForcesAndSourcesCore::getMaxRowOrder
int getMaxRowOrder() const
Get max order of approximation for field in rows.
Definition: ForcesAndSourcesCore.cpp:131
EntityHandle
MoFEM::FlatPrismElementForcesAndSourcesCore::FlatPrismElementForcesAndSourcesCore
FlatPrismElementForcesAndSourcesCore(Interface &m_field)
Definition: FlatPrismElementForcesAndSourcesCore.cpp:11
NOBASE
@ NOBASE
Definition: definitions.h:59
CHK_THROW_MESSAGE
#define CHK_THROW_MESSAGE(err, msg)
Check and throw MoFEM exception.
Definition: definitions.h:596
L2
@ L2
field with C-1 continuity
Definition: definitions.h:88
QUAD_2D_TABLE
static QUAD *const QUAD_2D_TABLE[]
Definition: quad.h:175
MoFEM::FlatPrismElementForcesAndSourcesCore::coordsAtGaussPts
MatrixDouble coordsAtGaussPts
Definition: FlatPrismElementForcesAndSourcesCore.hpp:153
MoFEM::Exceptions::MoFEMErrorCode
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
Definition: Exceptions.hpp:56
MoFEM::ForcesAndSourcesCore::setGaussPts
virtual MoFEMErrorCode setGaussPts(int order_row, int order_col, int order_data)
set user specific integration rule
Definition: ForcesAndSourcesCore.cpp:1926
MoFEM::CoreInterface::get_field_bit_number
virtual FieldBitNumber get_field_bit_number(const std::string name) const =0
get field bit number
MoFEM::ForcesAndSourcesCore::getMaxDataOrder
int getMaxDataOrder() const
Get max order of approximation for data fields.
Definition: ForcesAndSourcesCore.cpp:120
MoFEM::FieldName_mi_tag
MultiIndex Tag for field name.
Definition: TagMultiIndices.hpp:67
MoFEM::FlatPrismElementForcesAndSourcesCore::tAngent1_at_GaussPtF4
MatrixDouble tAngent1_at_GaussPtF4
Definition: FlatPrismElementForcesAndSourcesCore.hpp:163
QUAD_2D_TABLE_SIZE
#define QUAD_2D_TABLE_SIZE
Definition: quad.h:174
MoFEM::FlatPrismElementForcesAndSourcesCore::opHOCoordsAndNormals
OpGetCoordsAndNormalsOnPrism opHOCoordsAndNormals
Definition: FlatPrismElementForcesAndSourcesCore.hpp:165
MoFEM::ForcesAndSourcesCore::getElementPolynomialBase
auto & getElementPolynomialBase()
Get the Entity Polynomial Base object.
Definition: ForcesAndSourcesCore.hpp:90
MoFEM::ForcesAndSourcesCore::getMaxColOrder
int getMaxColOrder() const
Get max order of approximation for field in columns.
Definition: ForcesAndSourcesCore.cpp:135
MoFEM::EntitiesFieldData::spacesOnEntities
std::array< std::bitset< LASTSPACE >, MBMAXTYPE > spacesOnEntities
spaces on entity types
Definition: EntitiesFieldData.hpp:50
MoFEM::FlatPrismElementForcesAndSourcesCore::tAngent1_at_GaussPtF3
MatrixDouble tAngent1_at_GaussPtF3
Definition: FlatPrismElementForcesAndSourcesCore.hpp:159
order
constexpr int order
Definition: dg_projection.cpp:18
MoFEM::DeprecatedCoreInterface
Deprecated interface functions.
Definition: DeprecatedCoreInterface.hpp:16
MoFEM::ForcesAndSourcesCore::getEntityFieldData
MoFEMErrorCode getEntityFieldData(EntitiesFieldData &data, const int bit_number, const EntityType type_lo=MBVERTEX, const EntityType type_hi=MBPOLYHEDRON) const
Definition: ForcesAndSourcesCore.cpp:770
MoFEM::FlatPrismElementForcesAndSourcesCore::tAngent2_at_GaussPtF4
MatrixDouble tAngent2_at_GaussPtF4
Definition: FlatPrismElementForcesAndSourcesCore.hpp:164
MoFEM::FlatPrismElementForcesAndSourcesCore::coords
VectorDouble coords
Definition: FlatPrismElementForcesAndSourcesCore.hpp:152
MoFEM::BasicMethod::fieldsPtr
const Field_multiIndex * fieldsPtr
raw pointer to fields container
Definition: LoopMethods.hpp:252
ShapeDiffMBTRI
PetscErrorCode ShapeDiffMBTRI(double *diffN)
calculate derivatives of shape functions
Definition: fem_tools.c:194
MoFEM::FlatPrismElementForcesAndSourcesCore::UserDataOperator::setPtrFE
MoFEMErrorCode setPtrFE(ForcesAndSourcesCore *ptr)
Definition: FlatPrismElementForcesAndSourcesCore.cpp:237
CHKERR
#define CHKERR
Inline error check.
Definition: definitions.h:535
MoFEM::CoreInterface::get_moab
virtual moab::Interface & get_moab()=0
MoFEM
implementation of Data Operators for Forces and Sources
Definition: Common.hpp:10
MoFEM::FlatPrismElementForcesAndSourcesCore::nOrmals_at_GaussPtF3
MatrixDouble nOrmals_at_GaussPtF3
Definition: FlatPrismElementForcesAndSourcesCore.hpp:158
MoFEM::ForcesAndSourcesCore::dataOnElement
const std::array< boost::shared_ptr< EntitiesFieldData >, LASTSPACE > dataOnElement
Entity data on element entity rows fields.
Definition: ForcesAndSourcesCore.hpp:461
MoFEM::ForcesAndSourcesCore::createDataOnElement
MoFEMErrorCode createDataOnElement(EntityType type)
Create a entity data on element object.
Definition: ForcesAndSourcesCore.cpp:1305
MoFEM::FlatPrismPolynomialBase
Calculate base functions on tetrahedral.
Definition: FlatPrismPolynomialBase.hpp:44
ShapeFaceNormalMBTRI
PetscErrorCode ShapeFaceNormalMBTRI(double *diffN, const double *coords, double *normal)
Definition: fem_tools.c:229
QUAD_::npoints
int npoints
Definition: quad.h:29
LASTSPACE
@ LASTSPACE
FieldSpace in [ 0, LASTSPACE )
Definition: definitions.h:89
MoFEM::ForcesAndSourcesCore::getRule
virtual int getRule(int order_row, int order_col, int order_data)
another variant of getRule
Definition: ForcesAndSourcesCore.cpp:1920
AINSWORTH_LOBATTO_BASE
@ AINSWORTH_LOBATTO_BASE
Definition: definitions.h:62
MoFEM::FlatPrismElementForcesAndSourcesCore::hoCoordsAtGaussPtsF3
MatrixDouble hoCoordsAtGaussPtsF3
Definition: FlatPrismElementForcesAndSourcesCore.hpp:157
MoFEM::EntitiesFieldData::bAse
std::bitset< LASTBASE > bAse
bases on element
Definition: EntitiesFieldData.hpp:45
MoFEM::FlatPrismElementForcesAndSourcesCore::tAngent2_at_GaussPtF3
MatrixDouble tAngent2_at_GaussPtF3
Definition: FlatPrismElementForcesAndSourcesCore.hpp:160
MoFEM::ForcesAndSourcesCore::getSpacesAndBaseOnEntities
MoFEMErrorCode getSpacesAndBaseOnEntities(EntitiesFieldData &data) const
Get field approximation space and base on entities.
Definition: ForcesAndSourcesCore.cpp:990
MoFEM::ForcesAndSourcesCore
structure to get information form mofem into EntitiesFieldData
Definition: ForcesAndSourcesCore.hpp:22
MoFEM::FlatPrismElementForcesAndSourcesCore::nOrmals_at_GaussPtF4
MatrixDouble nOrmals_at_GaussPtF4
Definition: FlatPrismElementForcesAndSourcesCore.hpp:162
MoFEM::FlatPrismElementForcesAndSourcesCore::aRea
double aRea[2]
Definition: FlatPrismElementForcesAndSourcesCore.hpp:150
MoFEM::ForcesAndSourcesCore::dataH1
EntitiesFieldData & dataH1
Definition: ForcesAndSourcesCore.hpp:471
FTensor::dd
const Tensor2_symmetric_Expr< const ddTensor0< T, Dim, i, j >, typename promote< T, double >::V, Dim, i, j > dd(const Tensor0< T * > &a, const Index< i, Dim > index1, const Index< j, Dim > index2, const Tensor1< int, Dim > &d_ijk, const Tensor1< double, Dim > &d_xyz)
Definition: ddTensor0.hpp:33
MoFEM::FlatPrismElementForcesAndSourcesCore
FlatPrism finite element.
Definition: FlatPrismElementForcesAndSourcesCore.hpp:27
AINSWORTH_LEGENDRE_BASE
@ AINSWORTH_LEGENDRE_BASE
Ainsworth Cole (Legendre) approx. base .
Definition: definitions.h:60
HCURL
@ HCURL
field with continuous tangents
Definition: definitions.h:86
MOFEM_DATA_INCONSISTENCY
@ MOFEM_DATA_INCONSISTENCY
Definition: definitions.h:31
MoFEM::ForcesAndSourcesCore::gaussPts
MatrixDouble gaussPts
Matrix of integration points.
Definition: ForcesAndSourcesCore.hpp:109
MoFEM::FlatPrismPolynomialBaseCtx
Class used to pass element data to calculate base functions on flat prism.
Definition: FlatPrismPolynomialBase.hpp:21
MoFEM::FlatPrismElementForcesAndSourcesCore::hoCoordsAtGaussPtsF4
MatrixDouble hoCoordsAtGaussPtsF4
Definition: FlatPrismElementForcesAndSourcesCore.hpp:161
FieldApproximationBase
FieldApproximationBase
approximation base
Definition: definitions.h:58
MoFEM::EntitiesFieldData::dataOnEntities
std::array< boost::ptr_vector< EntData >, MBMAXTYPE > dataOnEntities
Definition: EntitiesFieldData.hpp:56
MoFEM::ForcesAndSourcesCore::loopOverOperators
MoFEMErrorCode loopOverOperators()
Iterate user data operators.
Definition: ForcesAndSourcesCore.cpp:1347
MoFEM::FEMethod::numeredEntFiniteElementPtr
boost::shared_ptr< const NumeredEntFiniteElement > numeredEntFiniteElementPtr
Definition: LoopMethods.hpp:383
MoFEMFunctionBeginHot
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:440
MoFEM::field_it
Field_multiIndex::index< FieldName_mi_tag >::type::iterator field_it
Definition: Projection10NodeCoordsOnField.cpp:123
MoFEM::ForcesAndSourcesCore::getNodesFieldData
MoFEMErrorCode getNodesFieldData(EntitiesFieldData &data, const int bit_number) const
Get data on nodes.
Definition: ForcesAndSourcesCore.cpp:642
MoFEM::EntitiesFieldData
data structure for finite element entity
Definition: EntitiesFieldData.hpp:40
MoFEM::FlatPrismElementForcesAndSourcesCore::meshPositionsFieldName
std::string meshPositionsFieldName
Definition: FlatPrismElementForcesAndSourcesCore.hpp:155
MoFEMFunctionReturn
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:416
HDIV
@ HDIV
field with continuous normal traction
Definition: definitions.h:87
MOFEM_NOT_IMPLEMENTED
@ MOFEM_NOT_IMPLEMENTED
Definition: definitions.h:32
MoFEM::ForcesAndSourcesCore::UserDataOperator::ptrFE
ForcesAndSourcesCore * ptrFE
Definition: ForcesAndSourcesCore.hpp:984
MoFEM::FlatPrismElementForcesAndSourcesCore::operator()
MoFEMErrorCode operator()()
function is run for every finite element
Definition: FlatPrismElementForcesAndSourcesCore.cpp:25
MoFEM::FlatPrismElementForcesAndSourcesCore::normal
VectorDouble normal
Definition: FlatPrismElementForcesAndSourcesCore.hpp:151
MoFEMFunctionBegin
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:346
MoFEM::ForcesAndSourcesCore::mField
Interface & mField
Definition: ForcesAndSourcesCore.hpp:24
MoFEM::OpGetCoordsAndNormalsOnPrism::calculateNormals
MoFEMErrorCode calculateNormals()
Definition: DataOperators.cpp:467
ShapeMBTRI
PetscErrorCode ShapeMBTRI(double *N, const double *X, const double *Y, const int G_DIM)
calculate shape functions on triangle
Definition: fem_tools.c:182