14 meshPositionsFieldName(
"MESH_NODE_POSITIONS"), coords(24), jAc(3, 3),
16 opContravariantPiolaTransform(elementMeasure, jAc),
17 opCovariantPiolaTransform(
invJac), opSetInvJacHdivAndHcurl(
invJac),
18 tJac(&jAc(0, 0), &jAc(0, 1), &jAc(0, 2), &jAc(1, 0), &jAc(1, 1),
19 &jAc(1, 2), &jAc(2, 0), &jAc(2, 1), &jAc(2, 2)),
36 auto get_rule_by_type = [&]() {
39 return getRule(order_row + 1, order_col + 1, order_data + 1);
41 return getRule(order_row, order_col, order_data);
45 const int rule = get_rule_by_type();
47 auto calc_base_for_tet = [&]() {
49 const size_t nb_gauss_pts =
gaussPts.size2();
52 base.resize(nb_gauss_pts, 4,
false);
53 diff_base.resize(nb_gauss_pts, 12,
false);
56 double *diff_shape_ptr = &*diff_base.data().begin();
57 for (
int gg = 0; gg != nb_gauss_pts; ++gg) {
58 for (
int nn = 0; nn != 4; ++nn) {
59 for (
int dd = 0; dd != 3; ++dd, ++diff_shape_ptr) {
67 auto calc_base_for_hex = [&]() {
69 const size_t nb_gauss_pts =
gaussPts.size2();
72 base.resize(nb_gauss_pts, 8,
false);
73 diff_base.resize(nb_gauss_pts, 24,
false);
74 for (
int gg = 0; gg != nb_gauss_pts; ++gg) {
114 auto set_integration_pts_for_hex = [&]() {
121 auto set_integration_pts_for_tet = [&]() {
123 const auto xiao_rule =
127 "Xiao--Gimbutas tetrahedron rule is available for polynomial "
128 "orders 0 to %d; requested %d",
131 if (xiao_rule->numBarycentricCoordinates != 4) {
133 "wrong number of tetrahedron barycentric coordinates");
136 const size_t nb_gauss_pts = xiao_rule->numPoints;
137 gaussPts.resize(4, nb_gauss_pts,
false);
138 cblas_dcopy(nb_gauss_pts, &xiao_rule->points[1], 4, &
gaussPts(0, 0), 1);
139 cblas_dcopy(nb_gauss_pts, &xiao_rule->points[2], 4, &
gaussPts(1, 0), 1);
140 cblas_dcopy(nb_gauss_pts, &xiao_rule->points[3], 4, &
gaussPts(2, 0), 1);
141 cblas_dcopy(nb_gauss_pts, xiao_rule->weights, 1, &
gaussPts(3, 0), 1);
145 base.resize(nb_gauss_pts, 4,
false);
146 diff_base.resize(nb_gauss_pts, 12,
false);
147 double *shape_ptr = &*base.data().begin();
148 cblas_dcopy(4 * nb_gauss_pts, xiao_rule->points, 1, shape_ptr, 1);
149 double *diff_shape_ptr = &*diff_base.data().begin();
150 for (
int gg = 0; gg != nb_gauss_pts; ++gg) {
151 for (
int nn = 0; nn != 4; ++nn) {
152 for (
int dd = 0;
dd != 3; ++
dd, ++diff_shape_ptr) {
163 CHKERR set_integration_pts_for_tet();
166 CHKERR set_integration_pts_for_hex();
167 CHKERR calc_base_for_hex();
171 "Element type not implemented: %d",
type);
176 const size_t nb_gauss_pts =
gaussPts.size2();
180 CHKERR calc_base_for_tet();
183 CHKERR calc_base_for_hex();
187 "Element type not implemented: %d",
type);
203 auto get_tet_t_diff_n = [&]() {
209 auto get_hex_t_diff_n = [&]() {
216 auto get_t_diff_n = [&]() {
218 return get_tet_t_diff_n();
219 return get_hex_t_diff_n();
222 auto t_diff_n = get_t_diff_n();
231 tJac(
i,
j) += t_coords(
i) * t_diff_n(
j);
258 double *shape_functions_ptr = &*shape_functions.data().begin();
259 const size_t nb_base_functions = shape_functions.size2();
260 const size_t nb_gauss_pts =
gaussPts.size2();
267 shape_functions_ptr);
268 for (
unsigned int gg = 0; gg != nb_gauss_pts; ++gg) {
271 for (
int bb = 0; bb != nb_base_functions; ++bb) {
272 t_coords_at_gauss_ptr(
i) += t_coords(
i) * t_shape_functions;
276 ++t_coords_at_gauss_ptr;
289 auto dim_type = CN::Dimension(
type);
291 auto get_data_on_ents = [&](
auto lower_dim,
auto space) {
296 for (
auto dd = dim_type; dd >= lower_dim; --dd) {
297 int nb_ents = moab::CN::NumSubEntities(
type, dd);
298 for (
int ii = 0; ii != nb_ents; ++ii) {
299 auto sub_ent_type = moab::CN::SubEntityType(
type, dd, ii);
301 auto &data_on_ent = data->dataOnEntities[sub_ent_type];
304 data->spacesOnEntities[sub_ent_type].set(space);
329 if ((data.
getDiffN(base).size1() == 4) &&
330 (data.
getDiffN(base).size2() == 3)) {
331 const size_t nb_gauss_pts =
gaussPts.size2();
332 const size_t nb_base_functions = 4;
333 new_diff_n.resize(nb_gauss_pts, 3 * nb_base_functions,
false);
334 double *new_diff_n_ptr = &*new_diff_n.data().begin();
336 new_diff_n_ptr, &new_diff_n_ptr[1], &new_diff_n_ptr[2]);
337 double *t_diff_n_ptr = &*data.
getDiffN(base).data().begin();
338 for (
unsigned int gg = 0; gg != nb_gauss_pts; gg++) {
340 t_diff_n_ptr, &t_diff_n_ptr[1], &t_diff_n_ptr[2]);
341 for (
unsigned int bb = 0; bb != nb_base_functions; bb++) {
342 t_new_diff_n(
i) = t_diff_n(
i);
347 data.
getDiffN(base).resize(new_diff_n.size1(), new_diff_n.size2(),
349 data.
getDiffN(base).swap(new_diff_n);
357 std::array<std::bitset<LASTSPACE>, 4> spaces_by_dim{
359 std::bitset<LASTSPACE>(0),
360 std::bitset<LASTSPACE>(0),
361 std::bitset<LASTSPACE>(0),
362 std::bitset<LASTSPACE>(0)
371 spaces_by_dim[1].test(
HCURL) ||
372 spaces_by_dim[2].test(
HCURL) ||
373 spaces_by_dim[3].test(
HCURL)
380 if (spaces_by_dim[2].test(
HDIV) || spaces_by_dim[3].test(
HDIV)) {
386 for (
auto t : {MBTRI, MBTET}) {
389 d.getDiffN(base) /= 6;
397 if (spaces_by_dim[3].test(
L2)) {
409 "User operator and finite element do not work together");
FieldApproximationBase
approximation base
@ AINSWORTH_LEGENDRE_BASE
Ainsworth Cole (Legendre) approx. base .
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
@ L2
field with C-1 continuity
@ HCURL
field with continuous tangents
@ HDIV
field with continuous normal traction
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
@ MOFEM_DATA_INCONSISTENCY
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define CHKERR
Inline error check.
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
#define MOFEM_LOG(channel, severity)
Log.
FTensor::Index< 'i', SPACE_DIM > i
const double n
refractive index of diffusive medium
FTensor::Index< 'j', 3 > j
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)
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
const Rule * getTetrahedronRule(const int order)
implementation of Data Operators for Forces and Sources
MoFEMErrorCode invertTensor3by3(ublas::matrix< T, L, A > &jac_data, ublas::vector< T, A > &det_data, ublas::matrix< T, L, A > &inv_jac_data)
Calculate inverse of tensor rank 2 at integration points.
static auto determinantTensor3by3(T &t)
Calculate the determinant of a 3x3 matrix or a tensor of rank 2.
constexpr double t
plate stiffness
virtual moab::Interface & get_moab()=0
virtual MPI_Comm & get_comm() const =0
virtual MoFEMErrorCode opRhs(EntitiesFieldData &data, const bool error_if_no_base=false)
Deprecated interface functions.
Data on single entity (This is passed as argument to DataOperator::doWork)
MatrixDouble & getDiffN(const FieldApproximationBase base)
get derivatives of base functions
MatrixInt facesNodes
nodes on finite element faces
std::array< std::bitset< LASTSPACE >, MBMAXTYPE > spacesOnEntities
spaces on entity types
std::array< boost::ptr_vector< EntData >, MBMAXTYPE > dataOnEntities
MatrixInt facesNodesOrder
order of face nodes on element
boost::shared_ptr< const NumeredEntFiniteElement > numeredEntFiniteElementPtr
Shared pointer to finite element database structure.
ForcesAndSourcesCore * ptrFE
virtual MoFEMErrorCode setPtrFE(ForcesAndSourcesCore *ptr)
structure to get information from mofem into EntitiesFieldData
int getMaxRowOrder() const
Get max order of approximation for field in rows.
MoFEMErrorCode calHierarchicalBaseFunctionsOnElement()
Calculate base functions.
MoFEMErrorCode loopOverOperators()
Iterate user data operators.
EntitiesFieldData & dataHdiv
MoFEMErrorCode getEntityDataOrder(const EntityType type, const FieldSpace space, boost::ptr_vector< EntitiesFieldData::EntData > &data) const
Get the entity data order.
virtual MoFEMErrorCode setGaussPts(int order_row, int order_col, int order_data)
set user specific integration rule
EntitiesFieldData & dataHcurl
int getMaxDataOrder() const
Get max order of approximation for data fields.
auto & getElementPolynomialBase()
Get the Entity Polynomial Base object.
EntitiesFieldData & dataH1
MoFEMErrorCode getSpacesAndBaseOnEntities(EntitiesFieldData &data) const
Get field approximation space and base on entities.
MatrixDouble coordsAtGaussPts
coordinated at gauss points
int getMaxColOrder() const
Get max order of approximation for field in columns.
const std::array< boost::shared_ptr< EntitiesFieldData >, LASTSPACE > dataOnElement
Entity data on element entity rows fields.
MatrixDouble gaussPts
Matrix of integration points.
MoFEMErrorCode getFaceNodes(EntitiesFieldData &data) const
Get nodes on faces.
EntityType lastEvaluatedElementEntityType
Last evaluated type of element entity.
virtual int getRule(int order_row, int order_col, int order_data)
another variant of getRule
MoFEMErrorCode createDataOnElement(EntityType type)
Create a entity data on element object.
MoFEMErrorCode getEntitySense(const EntityType type, boost::ptr_vector< EntitiesFieldData::EntData > &data) const
get sense (orientation) of entity
MoFEMErrorCode calBernsteinBezierBaseFunctionsOnElement()
Calculate Bernstein-Bezier base.
EntitiesFieldData & dataL2
Calculate base functions on tetrahedral.
Calculate base functions on tetrahedral.
Volume finite element base.
OpSetInvJacHdivAndHcurl opSetInvJacHdivAndHcurl
FTensor::Tensor2< double *, 3, 3 > tJac
VolumeElementForcesAndSourcesCore(Interface &m_field)
virtual MoFEMErrorCode transformBaseFunctions()
Transform base functions based on geometric element Jacobian.
virtual MoFEMErrorCode setIntegrationPts()
Set integration points.
MoFEMErrorCode operator()()
Main operator function executed for each loop iteration.
OpSetCovariantPiolaTransform opCovariantPiolaTransform
FTensor::Tensor2< double *, 3, 3 > tInvJac
virtual MoFEMErrorCode getSpaceBaseAndOrderOnElement()
Determine approximation space and order of base functions.
virtual MoFEMErrorCode calculateVolumeAndJacobian()
Calculate element volume and Jacobian.
virtual MoFEMErrorCode calculateCoordinatesAtGaussPts()
Calculate coordinate at integration points.
OpSetContravariantPiolaTransform opContravariantPiolaTransform
const EntityHandle * conn
OpSetInvJacH1 opSetInvJacH1
double zeta
Viscous hardening.