8 #ifndef __MAGNETICELEMENT_HPP__
9 #define __MAGNETICELEMENT_HPP__
104 if (
bit->getName().compare(0, 9,
"NATURALBC") == 0) {
122 ParallelComm *pcomm =
126 if (
bit->getName().compare(0, 10,
"ESSENTIALBC") == 0) {
140 CHKERR skin.find_skin(0, tets,
false, skin_faces);
143 CHKERR pcomm->filter_pstatus(skin_faces,
144 PSTATUS_SHARED | PSTATUS_MULTISHARED,
145 PSTATUS_NOT, -1, &proc_skin);
206 "MESH_NODE_POSITIONS");
218 Projection10NodeCoordsOnField ent_method_material(
mField,
219 "MESH_NODE_POSITIONS");
245 "MESH_NODE_POSITIONS");
323 auto material_grad_mat = boost::make_shared<MatrixDouble>();
324 auto material_det_vec = boost::make_shared<VectorDouble>();
325 auto material_inv_grad_mat = boost::make_shared<MatrixDouble>();
333 new OpGetHONormalsOnFace(
"MESH_NODE_POSITIONS"));
335 new OpCalculateHOCoords(
"MESH_NODE_POSITIONS"));
337 new OpHOSetCovariantPiolaTransformOnFace3D(
HCURL));
349 ->createMPIAIJ<PetscGlobalIdx_mi_tag>(problem_ptr->
getName(),
370 CHKERR KSPCreate(PETSC_COMM_WORLD, &solver);
372 CHKERR KSPSetFromOptions(solver);
375 CHKERR KSPDestroy(&solver);
382 if (regression_test) {
386 const double expected_value = 4.6772e+01;
387 const double tol = 1e-4;
388 if ((nrm2 - expected_value) / expected_value >
tol) {
390 "Regression test failed %6.4e != %6.4e", nrm2, expected_value);
409 PostProcBrokenMeshInMoab<VolumeElementForcesAndSourcesCore> post_proc(
415 auto pos_ptr = boost::make_shared<MatrixDouble>();
416 auto field_val_ptr = boost::make_shared<MatrixDouble>();
418 post_proc.getOpPtrVector().push_back(
419 new OpCalculateVectorFieldValues<3>(
"MESH_NODE_POSITIONS", pos_ptr));
420 post_proc.getOpPtrVector().push_back(
423 using OpPPMap = OpPostProcMapInMoab<3, 3>;
425 post_proc.getOpPtrVector().push_back(
429 post_proc.getPostProcMesh(), post_proc.getMapGaussPts(),
433 {{
"MESH_NODE_POSITIONS", pos_ptr},
434 {blockData.fieldName, field_val_ptr}},
444 post_proc.getOpPtrVector().push_back(
new OpPostProcessCurl(
445 blockData, post_proc.getPostProcMesh(), post_proc.getMapGaussPts()));
448 CHKERR post_proc.writeFile(
"out_values.h5m");
495 if (row_type == MBVERTEX)
497 if (col_type == MBVERTEX)
500 const int nb_row_dofs = row_data.getN().size2() / 3;
501 if (nb_row_dofs == 0)
503 const int nb_col_dofs = col_data.getN().size2() / 3;
504 if (nb_col_dofs == 0)
506 entityLocalMatrix.resize(nb_row_dofs, nb_col_dofs,
false);
507 entityLocalMatrix.clear();
509 if (nb_row_dofs !=
static_cast<int>(row_data.getFieldData().size())) {
511 "Number of base functions and DOFs on entity is different on "
513 nb_row_dofs, row_data.getFieldData().size());
515 if (nb_col_dofs !=
static_cast<int>(col_data.getFieldData().size())) {
518 "Number of base functions and DOFs on entity is different on cols",
519 nb_col_dofs, col_data.getFieldData().size());
527 const double c0 = 1. / blockData.
mU;
528 const int nb_gauss_pts = row_data.getN().size1();
529 auto t_row_curl_base = row_data.getFTensor2DiffN<3, 3>();
531 for (
int gg = 0; gg != nb_gauss_pts; gg++) {
534 double w = getGaussPts()(3, gg) * getVolume();
537 for (
int aa = 0; aa != nb_row_dofs; aa++) {
543 auto t_col_curl_base = col_data.getFTensor2DiffN<3, 3>(gg, 0);
544 for (
int bb = 0; bb != nb_col_dofs; bb++) {
546 t_local_mat += c0 *
w * t_row_curl(
i) * t_col_curl(
i);
556 nb_col_dofs, &col_data.getIndices()[0],
557 &entityLocalMatrix(0, 0), ADD_VALUES);
559 if (row_side != col_side || row_type != col_type) {
560 entityLocalMatrix = trans(entityLocalMatrix);
562 nb_row_dofs, &row_data.getIndices()[0],
563 &entityLocalMatrix(0, 0), ADD_VALUES);
609 if (row_type == MBVERTEX)
611 if (col_type == MBVERTEX)
614 const int nb_row_dofs = row_data.getN().size2() / 3;
615 if (nb_row_dofs == 0)
617 const int nb_col_dofs = col_data.getN().size2() / 3;
618 if (nb_col_dofs == 0)
620 entityLocalMatrix.resize(nb_row_dofs, nb_col_dofs,
false);
621 entityLocalMatrix.clear();
623 if (nb_row_dofs !=
static_cast<int>(row_data.getFieldData().size())) {
625 "Number of base functions and DOFs on entity is different on "
627 nb_row_dofs, row_data.getFieldData().size());
629 if (nb_col_dofs !=
static_cast<int>(col_data.getFieldData().size())) {
632 "Number of base functions and DOFs on entity is different on cols",
633 nb_col_dofs, col_data.getFieldData().size());
639 const double c0 = 1. / blockData.
mU;
640 const double c1 = blockData.
ePsilon * c0;
641 const int nb_gauss_pts = row_data.getN().size1();
643 for (
int gg = 0; gg != nb_gauss_pts; gg++) {
646 double w = getGaussPts()(3, gg) * getVolume();
649 &row_data.getVectorN<3>(gg)(0,
HVEC0),
650 &row_data.getVectorN<3>(gg)(0,
HVEC1),
651 &row_data.getVectorN<3>(gg)(0,
HVEC2), 3);
653 for (
int aa = 0; aa != nb_row_dofs; aa++) {
656 &col_data.getVectorN<3>(gg)(0,
HVEC0),
657 &col_data.getVectorN<3>(gg)(0,
HVEC1),
658 &col_data.getVectorN<3>(gg)(0,
HVEC2), 3);
659 for (
int bb = 0; bb != nb_col_dofs; bb++) {
660 t_local_mat += c1 *
w * t_row_base(
i) * t_col_base(
i);
672 nb_col_dofs, &col_data.getIndices()[0],
673 &entityLocalMatrix(0, 0), ADD_VALUES);
675 if (row_side != col_side || row_type != col_type) {
676 entityLocalMatrix = trans(entityLocalMatrix);
678 nb_row_dofs, &row_data.getIndices()[0],
679 &entityLocalMatrix(0, 0), ADD_VALUES);
723 if (row_type == MBVERTEX)
726 const int nb_row_dofs = row_data.getN().size2() / 3;
727 if (nb_row_dofs == 0)
729 naturalBC.resize(nb_row_dofs,
false);
734 const int nb_gauss_pts = row_data.getN().size1();
735 auto t_row_base = row_data.getFTensor1N<3>();
737 for (
int gg = 0; gg != nb_gauss_pts; gg++) {
741 area = norm_2(getNormalsAtGaussPts(gg)) * 0.5;
742 double w = getGaussPts()(2, gg) * area;
746 const double x = getCoordsAtGaussPts()(gg, 0);
747 const double y = getCoordsAtGaussPts()(gg, 1);
748 const double r = sqrt(x * x + y * y);
762 for (
int aa = 0; aa != nb_row_dofs; aa++) {
763 t_f +=
w * t_row_base(
i) * t_j(
i);
770 &row_data.getIndices()[0], &naturalBC[0], ADD_VALUES);
787 std::vector<EntityHandle> &map_gauss_pts)
790 blockData(data), postProcMesh(post_proc_mesh),
791 mapGaussPts(map_gauss_pts) {}
797 if (row_type == MBVERTEX)
801 double def_val[] = {0, 0, 0};
802 CHKERR postProcMesh.tag_get_handle(
"MAGNETIC_INDUCTION_FIELD", 3,
804 MB_TAG_CREAT | MB_TAG_SPARSE, def_val);
805 const int nb_row_dofs = row_data.getN().size2() / 3;
806 if (nb_row_dofs == 0)
808 const void *tags_ptr[mapGaussPts.size()];
810 if (nb_row_dofs != row_data.getFieldData().size())
812 "Wrong number of base functions and DOFs %d != %d",
813 nb_row_dofs, row_data.getFieldData().size());
818 const int nb_gauss_pts = row_data.getN().size1();
819 if (nb_gauss_pts !=
static_cast<int>(mapGaussPts.size())) {
821 "Inconsistency number of dofs %d!=%d", nb_gauss_pts,
824 CHKERR postProcMesh.tag_get_by_ptr(
th, &mapGaussPts[0],
825 mapGaussPts.size(), tags_ptr);
826 auto t_curl_base = row_data.getFTensor2DiffN<3, 3>();
827 for (
int gg = 0; gg != nb_gauss_pts; gg++) {
830 double *ptr = &((
double *)tags_ptr[gg])[0];
834 auto t_dof = row_data.getFTensor0FieldData();
835 for (
int aa = 0; aa != nb_row_dofs; aa++) {
846 #endif //__MAGNETICELEMENT_HPP__