12namespace bio = boost::iostreams;
18static char help[] =
"...\n\n";
20int main(
int argc,
char *argv[]) {
26 moab::Core mb_instance;
27 moab::Interface &moab = mb_instance;
29 MPI_Comm_rank(PETSC_COMM_WORLD, &rank);
31 PetscBool flg = PETSC_TRUE;
33#if PETSC_VERSION_GE(3, 6, 4)
40 if (flg != PETSC_TRUE) {
41 SETERRQ(PETSC_COMM_SELF, 1,
"*** ERROR -my_file (MESH FILE NEEDED)");
117 typedef tee_device<std::ostream, std::ofstream>
TeeDevice;
127 PrintJacobian(
TeeStream &_my_split) : my_split(_my_split) {}
129 ~PrintJacobian() { my_split.close(); }
134 const double eps = 1e-6;
135 for (
unsigned int ii = 0; ii != data.
getDiffN().size1(); ii++) {
136 for (
unsigned int jj = 0; jj != data.
getDiffN().size2(); jj++) {
142 my_split <<
"side: " << side <<
" type: " << type << std::fixed
143 << std::setprecision(4) << data.
getDiffN() << std::endl;
152 PrintJacobian opPrintJac;
158 ofs(
"forces_and_sources_calculate_jacobian.txt"),
159 my_tee(std::cout, ofs), my_split(my_tee),
invJac(3, 3),
160 opPrintJac(my_split), opSetInvJac(
invJac),
161 opGetData_FIELD1(dataFIELD1, dataDiffFIELD1), data(MBTET) {}
175 CHKERR getEntitySense<MBEDGE>(data);
176 CHKERR getEntitySense<MBTRI>(data);
177 CHKERR getEntityDataOrder<MBEDGE>(data,
H1);
178 CHKERR getEntityDataOrder<MBTRI>(data,
H1);
179 CHKERR getEntityDataOrder<MBTET>(data,
H1);
182 const auto bit_number = mField.get_field_bit_number(
"FIELD1");
190 for (
int gg = 0; gg < 4; gg++) {
198 boost::shared_ptr<BaseFunctionCtx>(
201 EntityHandle ent = numeredEntFiniteElementPtr->getEnt();
204 CHKERR mField.get_moab().get_connectivity(ent, conn, num_nodes,
true);
205 coords.resize(num_nodes * 3);
206 CHKERR mField.get_moab().get_coords(conn, num_nodes,
207 &*coords.data().begin());
211 &*coords.begin(), &*
invJac.data().begin());
215 CHKERR opPrintJac.opRhs(data);
218 my_split <<
"data FIELD1:" << std::endl;
219 my_split << dataFIELD1 << std::endl;
220 my_split <<
"data diff FIELD1:" << std::endl;
221 my_split << dataDiffFIELD1 << std::endl;
232 ForcesAndSourcesCore_TestFE fe1(m_field);
#define CATCH_ERRORS
Catch errors.
@ AINSWORTH_LEGENDRE_BASE
Ainsworth Cole (Legendre) approx. base .
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
#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 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 add_ents_to_finite_element_by_type(const EntityHandle entities, const EntityType type, const std::string &name, const bool recursive=true)=0
add entities to finite element
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 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.
virtual MoFEMErrorCode add_ents_to_field_by_type(const Range &ents, const EntityType type, const std::string &name, int verb=DEFAULT_VERBOSITY)=0
Add entities to field meshset.
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 partitionSimpleProblem(const std::string name, int verb=VERBOSE)
partition problem dofs
MoFEMErrorCode buildProblem(const std::string name, const bool square_matrix, int verb=VERBOSE)
build problem data structures
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
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
std::bitset< BITREFLEVEL_SIZE > BitRefLevel
Bit structure attached to each entity identifying to what mesh entity is attached.
implementation of Data Operators for Forces and Sources
PetscErrorCode PetscOptionsGetString(PetscOptions *, const char pre[], const char name[], char str[], size_t size, PetscBool *set)
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.
base operator to do operations at Gauss Pt. level
virtual MoFEMErrorCode opRhs(EntitiesFieldData &data, const bool error_if_no_base=false)
Deprecated interface functions.
Class used to pass element data to calculate base functions on tet,triangle,edge.
Data on single entity (This is passed as argument to DataOperator::doWork)
MatrixDouble & getDiffN(const FieldApproximationBase base)
get derivatives of base functions
data structure for finite element entity
std::array< boost::ptr_vector< EntData >, MBMAXTYPE > dataOnEntities
structure to get information form mofem into EntitiesFieldData
MoFEMErrorCode getEntityRowIndices(EntitiesFieldData &data, const int bit_number, const EntityType type_lo=MBVERTEX, const EntityType type_hi=MBPOLYHEDRON) const
MoFEMErrorCode getRowNodesIndices(EntitiesFieldData &data, const int bit_number) const
get row node indices from FENumeredDofEntity_multiIndex
MoFEMErrorCode getSpacesAndBaseOnEntities(EntitiesFieldData &data) const
Get field approximation space and base on entities.
virtual MoFEMErrorCode operator()()
function is run for every finite element
MoFEMErrorCode getFaceNodes(EntitiesFieldData &data) const
Get nodes on faces.
MoFEMErrorCode getEntityFieldData(EntitiesFieldData &data, const int bit_number, const EntityType type_lo=MBVERTEX, const EntityType type_hi=MBPOLYHEDRON) const
virtual MoFEMErrorCode preProcess()
function is run at the beginning of loop
MoFEMErrorCode getNodesFieldData(EntitiesFieldData &data, const int bit_number) const
Get data on nodes.
virtual MoFEMErrorCode postProcess()
function is run at the end of loop
Get field values and gradients at Gauss points.
Transform local reference derivatives of shape function to global derivatives.
Problem manager is used to build and partition problems.
Calculate base functions on tetrahedral.
MoFEMErrorCode getValue(MatrixDouble &pts, boost::shared_ptr< BaseFunctionCtx > ctx_ptr)
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface refernce to pointer of interface.