Testing integration on skeleton for 3D.
Checking continuity of hdiv and hcurl spaces on faces, and testing methods for integration on the skeleton.
static char help[] =
"...\n\n";
int main(
int argc,
char *argv[]) {
auto core_log = logging::core::get();
core_log->add_sink(
LogManager::createSink(LogManager::getStrmSelf(), "ATOM_TEST"));
LogManager::setLog("ATOM_TEST");
try {
moab::Core mb_instance;
moab::Interface &moab = mb_instance;
int rank;
MPI_Comm_rank(PETSC_COMM_WORLD, &rank);
PetscBool flg = PETSC_TRUE;
#if PETSC_VERSION_GE(3, 6, 4)
255, &flg);
#else
CHKERR PetscOptionsGetString(PETSC_NULL, PETSC_NULL,
"-my_file",
#endif
if (flg != PETSC_TRUE) {
SETERRQ(PETSC_COMM_SELF, 1, "*** ERROR -my_file (MESH FILE NEEDED)");
}
const char *option;
option = "";
0, 3, bit_level0);
enum bases { AINSWORTH, DEMKOWICZ, LASTBASEOP };
const char *list_bases[] = {"ainsworth", "demkowicz"};
PetscBool flg;
PetscInt choice_base_value = AINSWORTH;
CHKERR PetscOptionsGetEList(PETSC_NULL, NULL,
"-base", list_bases,
LASTBASEOP, &choice_base_value, &flg);
if (flg == PETSC_TRUE) {
if (choice_base_value == AINSWORTH)
else if (choice_base_value == DEMKOWICZ)
return base;
}
};
const char *list_spaces[] = {"hdiv", "hcurl"};
PetscBool flg;
PetscInt choice_space_value =
HDIV;
CHKERR PetscOptionsGetEList(PETSC_NULL, NULL,
"-space", list_spaces,
LASTSPACEOP, &choice_space_value, &flg);
if (flg == PETSC_TRUE) {
if (choice_space_value ==
HDIV)
else if (choice_space_value ==
HCURL)
return space;
}
};
};
struct OpVolSide
"F2", UserDataOperator::OPROW),
elemData(elem_data) {}
if (CN::Dimension(type) == 3) {
getCoordsAtGaussPts() - getFaceCoordsAtGaussPts();
<< "getCoordsAtGaussPts() " << getCoordsAtGaussPts();
<< "getFaceCoordsAtGaussPts() " << getFaceCoordsAtGaussPts();
constexpr double eps = 1e-12;
if (norm_inf(diff) >
eps) {
MOFEM_LOG(
"ATOM_TEST", Sev::error) <<
"diff " << diff;
"Coordinates at integration pts are different");
}
}
if (nb_dofs) {
const size_t nb_integration_pts = getGaussPts().size2();
auto t_to_do_dot = getFTensor1Normal();
auto s1 = getFTensor1Tangent1();
auto s2 = getFTensor1Tangent2();
t_to_do_dot(
i) = s1(
i) + s2(
i);
}
if (getFEMethod()->nInTheLoop == 0)
ptr_dot_elem_data = &elemData.dotNormalEleLeft;
else
ptr_dot_elem_data = &elemData.dotNormalEleRight;
auto &dot_elem_data = *ptr_dot_elem_data;
if (dot_elem_data.size() == 0) {
dot_elem_data.resize(nb_integration_pts, false);
dot_elem_data.clear();
}
for (size_t gg = 0; gg != nb_integration_pts; ++gg) {
for (size_t bb = 0; bb != nb_dofs; ++bb) {
dot_elem_data(gg) += (t_to_do_dot(
i) * t_hdiv_base(
i)) * t_data;
++t_hdiv_base;
++t_data;
}
}
}
}
};
"F2", UserDataOperator::OPROW),
volSideFe(m_field),
elemData(elem_data) {
auto jac_ptr = boost::make_shared<MatrixDouble>();
auto inv_jac_ptr = boost::make_shared<MatrixDouble>();
auto det_ptr = boost::make_shared<VectorDouble>();
}
const size_t nb_integration_pts =
getGaussPts().size2();
if (side == 0 && type == MBEDGE) {
elemData.dotNormalFace.resize(nb_integration_pts,
false);
}
if (nb_dofs) {
auto s1 = getFTensor1Tangent1();
auto s2 = getFTensor1Tangent2();
t_to_do_dot(
i) = s1(
i) + s2(
i);
}
for (size_t gg = 0; gg != nb_integration_pts; ++gg) {
for (size_t bb = 0; bb != nb_dofs; ++bb) {
(t_to_do_dot(
i) * t_hdiv_base(
i)) * t_data;
++t_hdiv_base;
++t_data;
}
}
}
if (CN::Dimension(type) == 2) {
elemData.dotNormalEleLeft.resize(0,
false);
elemData.dotNormalEleRight.resize(0,
false);
CHKERR loopSideVolumes(
"V1", volSideFe);
auto check_continuity_of_base = [&](auto &vol_dot_data) {
if (vol_dot_data.size() !=
elemData.dotNormalFace.size())
"Inconsistent number of integration points");
const double eps = 1e-12;
for (size_t gg = 0; gg != nb_integration_pts; ++gg) {
const double error =
std::abs(vol_dot_data(gg) -
elemData.dotNormalFace(gg));
MOFEM_LOG(
"ATOM_TEST", Sev::noisy) <<
"Error: " << error;
"Inconsistency %3.4e != %3.4e", vol_dot_data(gg),
}
};
if (
elemData.dotNormalEleLeft.size() != 0)
else if (
elemData.dotNormalEleRight.size() != 0)
}
}
};
face_fe.getRuleHook = [](int, int, int) { return 1; };
face_fe.getOpPtrVector().push_back(
face_fe.getOpPtrVector().push_back(
face_fe.getOpPtrVector().push_back(
new SkeletonFE(m_field, elem_data));
auto cache_ptr = boost::make_shared<CacheTuple>();
for (auto &ent_ptr : (*field_ents_ptr)) {
MOFEM_LOG(
"ATOM_TEST", Sev::verbose) << *ent_ptr;
for(
auto &
v : ent_ptr->getEntFieldData())
for (
auto &
v : ent_ptr->getEntFieldData())
}
}
return 0;
}
#define CATCH_ERRORS
Catch errors.
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()
FieldSpace
approximation spaces
@ LASTSPACE
FieldSpace in [ 0, LASTSPACE )
@ 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_ATOM_TEST_INVALID
#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 ...
virtual const FieldEntity_multiIndex * get_field_ents() const =0
Get the field ents object.
virtual MoFEMErrorCode add_ents_to_finite_element_by_dim(const EntityHandle entities, const int dim, const std::string &name, const bool recursive=true)=0
add entities to finite element
virtual MoFEMErrorCode add_finite_element(const std::string &fe_name, enum MoFEMTypes bh=MF_EXCL, int verb=DEFAULT_VERBOSITY)=0
add finite element
virtual MoFEMErrorCode build_finite_elements(int verb=DEFAULT_VERBOSITY)=0
Build finite elements.
virtual MoFEMErrorCode modify_finite_element_add_field_col(const std::string &fe_name, const std::string name_row)=0
set field col which finite element use
virtual MoFEMErrorCode modify_finite_element_add_field_data(const std::string &fe_name, const std::string name_filed)=0
set finite element field data
virtual MoFEMErrorCode modify_finite_element_add_field_row(const std::string &fe_name, const std::string name_row)=0
set field row which finite element use
virtual MoFEMErrorCode build_fields(int verb=DEFAULT_VERBOSITY)=0
virtual MoFEMErrorCode add_ents_to_field_by_dim(const Range &ents, const int dim, const std::string &name, int verb=DEFAULT_VERBOSITY)=0
Add entities to field meshset.
virtual MoFEMErrorCode set_field_order(const EntityHandle meshset, const EntityType type, const std::string &name, const ApproximationOrder order, int verb=DEFAULT_VERBOSITY)=0
Set order approximation of the entities in the field.
#define MOFEM_LOG(channel, severity)
Log.
virtual MoFEMErrorCode loop_finite_elements(const std::string problem_name, const std::string &fe_name, FEMethod &method, boost::shared_ptr< NumeredEntFiniteElement_multiIndex > fe_ptr=nullptr, MoFEMTypes bh=MF_EXIST, CacheTupleWeakPtr cache_ptr=CacheTupleSharedPtr(), int verb=DEFAULT_VERBOSITY)=0
Make a loop over finite elements.
MoFEMErrorCode partitionGhostDofs(const std::string name, int verb=VERBOSE)
determine ghost nodes
MoFEMErrorCode buildProblem(const std::string name, const bool square_matrix, int verb=VERBOSE)
build problem data structures
MoFEMErrorCode partitionProblem(const std::string name, int verb=VERBOSE)
partition problem dofs (collective)
MoFEMErrorCode partitionFiniteElements(const std::string name, bool part_from_moab=false, int low_proc=-1, int hi_proc=-1, int verb=VERBOSE)
partition finite elements
virtual MoFEMErrorCode add_problem(const std::string &name, enum MoFEMTypes bh=MF_EXCL, int verb=DEFAULT_VERBOSITY)=0
Add problem.
virtual MoFEMErrorCode modify_problem_ref_level_add_bit(const std::string &name_problem, const BitRefLevel &bit)=0
add ref level to problem
virtual MoFEMErrorCode modify_problem_add_finite_element(const std::string name_problem, const std::string &fe_name)=0
add finite element to problem, this add entities assigned to finite element to a particular problem
FTensor::Index< 'i', SPACE_DIM > i
const double v
phase velocity of light in medium (cm/ns)
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
UBlasMatrix< double > MatrixDouble
std::bitset< BITREFLEVEL_SIZE > BitRefLevel
Bit structure attached to each entity identifying to what mesh entity is attached.
UBlasVector< double > VectorDouble
implementation of Data Operators for Forces and Sources
virtual MoFEMErrorCode cache_problem_entities(const std::string prb_name, CacheTupleWeakPtr cache_ptr)=0
Cache variables.
virtual MoFEMErrorCode build_adjacencies(const Range &ents, int verb=DEFAULT_VERBOSITY)=0
build adjacencies
virtual MoFEMErrorCode add_field(const std::string &name, const FieldSpace space, const FieldApproximationBase base, const FieldCoefficientsNumber nb_of_coefficients, const TagType tag_type=MB_TAG_SPARSE, const enum MoFEMTypes bh=MF_EXCL, int verb=DEFAULT_VERBOSITY)=0
Add field.
static MoFEMErrorCode Initialize(int *argc, char ***args, const char file[], const char help[])
Initializes the MoFEM database PETSc, MOAB and MPI.
static MoFEMErrorCode Finalize()
Checks for options to be called at the conclusion of the program.
Deprecated interface functions.
auto getFTensor1Normal()
get edge normal NOTE: it should be used only in 2D analysis
Data on single entity (This is passed as argument to DataOperator::doWork)
const VectorDouble & getFieldData() const
get dofs values
FTensor::Tensor0< FTensor::PackPtr< double *, 1 > > getFTensor0FieldData()
Resturn scalar files as a FTensor of rank 0.
FTensor::Tensor1< FTensor::PackPtr< double *, Tensor_Dim >, Tensor_Dim > getFTensor1N(FieldApproximationBase base)
Get base functions for Hdiv/Hcurl spaces.
FieldSpace & getSpace()
Get field space.
default operator for TRI element
MatrixDouble & getGaussPts()
matrix of integration (Gauss) points for Volume Element
boost::ptr_deque< UserDataOperator > & getOpPtrVector()
Use to push back operator for row operator.
Set inverse jacobian to base functions.
Problem manager is used to build and partition problems.
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface refernce to pointer of interface.
default operator for TET element
Base volume element used to integrate on skeleton.
MoFEMErrorCode doWork(int side, EntityType type, EntitiesFieldData::EntData &data)
Operator for linear form, usually to calculate values on right hand side.