7namespace bio = boost::iostreams;
11static char help[] =
"...\n\n";
32 const double eps = 1e-12;
33 const int nb_gauss_pts = data.
getN().size1();
34 for (
int gg = 0; gg != nb_gauss_pts; gg++) {
37 str0(0, 0), str0(0, 1), str0(0, 2), str0(1, 0), str0(1, 1),
38 str0(1, 2), str0(2, 0), str0(2, 1), str0(2, 2));
41 str1[3], str1[4], str1[5],
42 str1[6], str1[7], str1[8]);
43 t_stress_0(
i,
j) -= t_stress_1(
i,
j);
44 double nrm2 = t_stress_0(
i,
j) * t_stress_0(
i,
j);
48 "derivative of energy and stress inconsistency nrm2 = %6.4e",
56int main(
int argc,
char *argv[]) {
62 enum materials { HOOKE, NEOHOOKEAN, LASTOP };
64 const char *materials_list[] = {
"HOOKE",
"NEOHOOKEAN"};
66 PetscBool flg_test_mat;
67 PetscInt choise_value = HOOKE;
69 LASTOP, &choise_value, &flg_test_mat);
71 moab::Core mb_instance;
72 moab::Interface &moab = mb_instance;
74 MPI_Comm_rank(PETSC_COMM_WORLD, &rank);
76 PetscBool flg = PETSC_TRUE;
103 if (flg != PETSC_TRUE) {
115 double scale_positions = 2;
121 if (dof_ptr->get()->getEntType() != MBVERTEX)
124 int dof_rank = dof_ptr->get()->getDofCoeffIdx();
125 double &fval = dof_ptr->get()->getFieldData();
127 CHKERR moab.get_coords(&ent, 1, coords);
130 fval = scale_positions * coords[dof_rank];
138 FunctionsToCalculatePiolaKirchhoffI<double>>(),
140 FunctionsToCalculatePiolaKirchhoffI<adouble>>());
176 std::map<int, NonlinearElasticElement::BlockData>::iterator sit =
181 "SPATIAL_POSITION", sit->second, elastic.
commonData, tag0,
182 false,
false,
false));
185 "SPATIAL_POSITION", sit->second, elastic.
commonData, tag1,
true,
186 false,
false,
false));
197 if (flg_test_mat == PETSC_TRUE) {
198 PetscPrintf(PETSC_COMM_WORLD,
"Testing %s\n",
199 materials_list[choise_value]);
200 std::map<int, NonlinearElasticElement::BlockData>::iterator sit =
203 switch (choise_value) {
205 sit->second.materialDoublePtr = boost::make_shared<Hooke<double>>();
206 sit->second.materialAdoublePtr = boost::make_shared<Hooke<adouble>>();
209 sit->second.materialDoublePtr =
210 boost::make_shared<NeoHookean<double>>();
211 sit->second.materialAdoublePtr =
212 boost::make_shared<NeoHookean<adouble>>();
Implementation of linear elastic material.
ForcesAndSourcesCore::UserDataOperator UserDataOperator
Implementation of Neo-Hookean elastic material.
#define CATCH_ERRORS
Catch errors.
@ AINSWORTH_LEGENDRE_BASE
Ainsworth Cole (Legendre) approx. base nme:nme847.
#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 ...
@ 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 _IT_GET_DOFS_FIELD_BY_NAME_FOR_LOOP_(MFIELD, NAME, IT)
virtual MoFEMErrorCode build_finite_elements(int verb=DEFAULT_VERBOSITY)=0
Build finite elements.
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 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
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 PetscOptionsGetInt(PetscOptions *, const char pre[], const char name[], PetscInt *ivalue, PetscBool *set)
PetscErrorCode PetscOptionsGetEList(PetscOptions *, const char pre[], const char name[], const char *const *list, PetscInt next, PetscInt *value, PetscBool *set)
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.
Deprecated interface functions.
Data on single entity (This is passed as argument to DataOperator::doWork)
MatrixDouble & getN(const FieldApproximationBase base)
get base functions this return matrix (nb. of rows is equal to nb. of Gauss pts, nb....
const VectorDouble & getFieldData() const
get dofs values
@ OPROW
operator doWork function is executed on FE rows
boost::ptr_deque< UserDataOperator > & getOpPtrVector()
Use to push back operator for row operator.
Problem manager is used to build and partition problems.
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.
Volume finite element base.
common data used by volume elements
std::vector< VectorDouble > jacEnergy
std::vector< MatrixDouble3by3 > sTress
Calculate explicit derivative of free energy.
Operator performs automatic differentiation.
structure grouping operators and data used for calculation of nonlinear elastic element
MoFEMErrorCode addElement(const std::string element_name, const std::string spatial_position_field_name, const std::string material_position_field_name="MESH_NODE_POSITIONS", const bool ale=false)
std::map< int, BlockData > setOfBlocks
maps block set id with appropriate BlockData
MoFEMErrorCode setBlocks(boost::shared_ptr< FunctionsToCalculatePiolaKirchhoffI< double > > materialDoublePtr, boost::shared_ptr< FunctionsToCalculatePiolaKirchhoffI< adouble > > materialAdoublePtr)
MyVolumeFE & getLoopFeRhs()
get rhs volume element
OpCheck(NonlinearElasticElement::CommonData &common_data)
FTensor::Index< 'j', 3 > j
FTensor::Index< 'i', 3 > i
NonlinearElasticElement::CommonData & commonData
MoFEMErrorCode doWork(int side, EntityType type, EntitiesFieldData::EntData &data)
Operator for linear form, usually to calculate values on right hand side.