14 meshPositionsFieldName(
"MESH_NODE_POSITIONS"), aRea(elementMeasure) {}
31 auto get_ftensor_n_diff = [&]() {
39 &
m(0, 0), &
m(0, 1), &
m(0, 2));
44 const size_t nb_gauss_pts =
gaussPts.size2();
60 for (
int gg = 0; gg != nb_gauss_pts; ++gg) {
69 }
else if (
type == MBQUAD) {
77 const size_t nb_gauss_pts =
gaussPts.size2();
92 auto t_diff = get_ftensor_n_diff();
93 for (
int gg = 0; gg != nb_gauss_pts; ++gg) {
94 auto t_coords = get_ftensor_from_vec_3d(
coords);
96 t_t1(
i) += t_coords(
i) * t_diff(N0);
97 t_t2(
i) += t_coords(
i) * t_diff(N1);
109 "Element type not implemented");
126 auto calc_normal = [&](
const double *diff_ptr) {
137 diff_ptr, &diff_ptr[1]);
148 for (
int nn = 0; nn !=
num_nodes; ++nn) {
149 t_t1(
i) += t_coords(
i) * t_diff(N0);
150 t_t2(
i) += t_coords(
i) * t_diff(N1);
155 aRea = sqrt(t_normal(
i) * t_normal(
i));
159 const double *diff_ptr;
163 CHKERR calc_normal(diff_ptr);
169 CHKERR calc_normal(diff_ptr);
173 "Element type not implemented");
188 auto get_rule_by_type = [&]() {
191 return getRule(order_row + 1, order_col + 1, order_data + 1);
193 return getRule(order_row, order_col, order_data);
197 const int rule = get_rule_by_type();
199 auto set_integration_pts_for_tri = [&]() {
204 "Xiao--Gimbutas triangle rule is available for polynomial "
205 "orders 0 to %d; requested %d",
208 if (xiao_rule->numBarycentricCoordinates != 3) {
210 "wrong number of triangle barycentric coordinates");
213 const size_t nb_gauss_pts = xiao_rule->numPoints;
214 gaussPts.resize(3, nb_gauss_pts,
false);
215 cblas_dcopy(nb_gauss_pts, &xiao_rule->points[1], 3, &
gaussPts(0, 0), 1);
216 cblas_dcopy(nb_gauss_pts, &xiao_rule->points[2], 3, &
gaussPts(1, 0), 1);
217 cblas_dcopy(nb_gauss_pts, xiao_rule->weights, 1, &
gaussPts(2, 0), 1);
222 cblas_dcopy(3 * nb_gauss_pts, xiao_rule->points, 1, shape_ptr, 1);
230 auto calc_base_for_tri = [&]() {
232 const size_t nb_gauss_pts =
gaussPts.size2();
235 base.resize(nb_gauss_pts, 3,
false);
236 diff_base.resize(3, 2,
false);
245 auto calc_base_for_quad = [&]() {
247 const size_t nb_gauss_pts =
gaussPts.size2();
250 base.resize(nb_gauss_pts, 4,
false);
251 diff_base.resize(nb_gauss_pts, 8,
false);
252 for (
int gg = 0; gg != nb_gauss_pts; ++gg) {
274 CHKERR set_integration_pts_for_tri();
279 CHKERR calc_base_for_quad();
283 "Element type not implemented: %d",
type);
289 const size_t nb_gauss_pts =
gaussPts.size2();
293 CHKERR calc_base_for_tri();
296 CHKERR calc_base_for_quad();
300 "Element type not implemented: %d",
type);
315 auto dim_type = CN::Dimension(
type);
317 auto get_data_on_ents = [&](
auto lower_dim,
auto space) {
320 for (
auto dd = dim_type; dd >= lower_dim; --dd) {
321 int nb_ents = moab::CN::NumSubEntities(
type, dd);
322 for (
int ii = 0; ii != nb_ents; ++ii) {
323 auto sub_ent_type = moab::CN::SubEntityType(
type, dd, ii);
325 auto &data_on_ent = data->dataOnEntities[sub_ent_type];
328 data->spacesOnEntities[sub_ent_type].set(space);
347 const size_t nb_nodes =
349 double *shape_functions =
351 const size_t nb_gauss_pts =
gaussPts.size2();
353 for (
int gg = 0; gg != nb_gauss_pts; ++gg)
354 for (
int dd = 0; dd != 3; ++dd)
356 nb_nodes, &shape_functions[nb_nodes * gg], 1, &
coords[dd], 3);
366 "User operator and finite element do not work together");
411FaceElementForcesAndSourcesCore::UserDataOperator::loopSideVolumes(
413 return loopSide(fe_name, &fe_method, 3);
421 if (toElePtr->gaussPts.size1() != getGaussPts().size1()) {
423 "Inconsistent numer of weights %zu != %zu",
424 toElePtr->gaussPts.size1(), getGaussPts().size1());
426 if (toElePtr->gaussPts.size2() != getGaussPts().size2()) {
428 "Inconsistent numer of integtaion pts %zu != %zu",
429 toElePtr->gaussPts.size2(), getGaussPts().size2());
434 switch (getFEType()) {
439 "Element type not implemented");
444 &
m(0, 0), &
m(0, 1), &
m(0, 2));
449 auto get_local_coords_triangle = [&]() {
450 std::array<double, 3> ksi0 = {0, 1, 0};
451 std::array<double, 3> ksi1 = {0, 0, 1};
452 std::array<double, 9> ref_shapes;
453 CHKERR Tools::shapeFunMBTRI<1>(ref_shapes.data(), ksi0.data(), ksi1.data(),
455 auto &node_coords = getCoords();
456 auto &glob_coords = toElePtr->coords;
457 std::array<double, 6> local_coords;
459 &*node_coords.begin(), &*glob_coords.begin(), 3, local_coords.data());
464 auto get_diff_triangle = [&]() {
467 diff_ptr, &diff_ptr[1]);
471 auto get_jac = [&](
auto &&local_coords,
auto &&t_diff) {
475 auto t_local_coords = getFTensor1FromPtr<2>(local_coords.data());
477 for (
int nn = 0; nn != 3; ++nn) {
478 t_jac(
I,
J) += t_local_coords(
I) * t_diff(
J);
486 auto t_mat_tangent = [&](
auto &t1,
auto &t2) {
488 &t1(0), &t1(1), &t1(2), &t2(0), &t2(1), &t2(2)};
492 auto transform = [&](
auto &&t_mat_t,
auto &&t_mat_out_t,
auto &&t_inv_jac) {
498 for (
auto gg = 0; gg != getGaussPts().size2(); ++gg) {
500 t_mat_out_t(
J,
i) = t_mat_t(
I,
i) * t_inv_jac(
I,
J);
507 auto calc_normal = [&](
auto &
n,
auto &t1,
auto &t2) {
511 auto t_t1 = get_ftensor_from_mat_3d(t1);
512 auto t_t2 = get_ftensor_from_mat_3d(t2);
513 auto t_n = get_ftensor_from_mat_3d(
n);
514 for (
auto gg = 0; gg != getGaussPts().size2(); ++gg) {
524 t_mat_tangent(getTangent1AtGaussPts(), getTangent2AtGaussPts()),
525 t_mat_tangent(toElePtr->tangentOneAtGaussPts,
526 toElePtr->tangentTwoAtGaussPts),
527 get_jac(get_local_coords_triangle(), get_diff_triangle())
530 calc_normal(toElePtr->normalsAtGaussPts, toElePtr->tangentOneAtGaussPts,
531 toElePtr->tangentTwoAtGaussPts);
static MoFEMErrorCode get_jac(EntitiesFieldData::EntData &col_data, int gg, MatrixDouble &jac_stress, MatrixDouble &jac)
#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 ...
FTensor::Index< 'i', SPACE_DIM > i
const double v
phase velocity of light in medium (cm/ns)
const double n
refractive index of diffusive medium
FTensor::Index< 'J', DIM1 > J
FTensor::Index< 'j', 3 > j
FTensor::Index< 'k', 3 > k
constexpr std::enable_if<(Dim0<=2 &&Dim1<=2), Tensor2_Expr< Levi_Civita< T >, T, Dim0, Dim1, i, j > >::type levi_civita(const Index< i, Dim0 > &, const Index< j, Dim1 > &)
levi_civita functions to make for easy adhoc use
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
const Rule * getTriangleRule(const int order)
implementation of Data Operators for Forces and Sources
constexpr IntegrationType I
FTensor::Index< 'm', 3 > m
virtual moab::Interface & get_moab()=0
virtual MPI_Comm & get_comm() const =0
Deprecated interface functions.
Data on single entity (This is passed as argument to DataOperator::doWork)
std::array< std::bitset< LASTSPACE >, MBMAXTYPE > spacesOnEntities
spaces on entity types
std::array< boost::ptr_vector< EntData >, MBMAXTYPE > dataOnEntities
boost::shared_ptr< const NumeredEntFiniteElement > numeredEntFiniteElementPtr
Shared pointer to finite element database structure.
MatrixDouble tangentOneAtGaussPts
virtual MoFEMErrorCode calculateAreaAndNormal()
Calculate element area and normal of the face.
MoFEMErrorCode operator()()
Main operator function executed for each loop iteration.
FaceElementForcesAndSourcesCore(Interface &m_field)
MatrixDouble normalsAtGaussPts
virtual MoFEMErrorCode getSpaceBaseAndOrderOnElement()
Determine approximation space and order of base functions.
virtual MoFEMErrorCode calculateAreaAndNormalAtIntegrationPts()
Calculate element area and normal of the face at integration points.
virtual MoFEMErrorCode setIntegrationPts()
Set integration points.
const EntityHandle * conn
virtual MoFEMErrorCode calculateCoordinatesAtGaussPts()
Calculate coordinate at integration points.
MatrixDouble tangentTwoAtGaussPts
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.
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
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.
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.
Copy geometry-related data from one element to other.
Calculate base functions on triangle.
Calculate base functions on triangle.
Base volume element used to integrate on skeleton.
double zeta
Viscous hardening.