13using namespace boost::numeric;
 
   18int main(
int argc, 
char *argv[]) {
 
   24  moab::Core mb_instance;              
 
   25  moab::Interface &moab = mb_instance; 
 
   32    PetscBool ale = PETSC_FALSE;
 
   34    PetscBool test_jacobian = PETSC_FALSE;
 
   48    if (ale == PETSC_TRUE) {
 
   67    if (ale == PETSC_TRUE) {
 
   73    boost::shared_ptr<ForcesAndSourcesCore> fe_lhs_ptr(
 
   75    boost::shared_ptr<ForcesAndSourcesCore> fe_rhs_ptr(
 
   80    fe_lhs_ptr->getRuleHook = 
VolRule();
 
   81    fe_rhs_ptr->getRuleHook = 
VolRule();
 
   89    boost::shared_ptr<map<int, BlockData>> block_sets_ptr =
 
   90        boost::make_shared<map<int, BlockData>>();
 
   91    (*block_sets_ptr)[0].
iD = 0;
 
   92    (*block_sets_ptr)[0].E = 1;
 
   93    (*block_sets_ptr)[0].PoissonRatio = 0.25;
 
   97    CHKERR HookeElement::setOperators(fe_lhs_ptr, fe_rhs_ptr, block_sets_ptr,
 
   98                                      "x", 
"X", ale, 
false);
 
  101    CHKERR DMCreateGlobalVector(dm, &x);
 
  102    CHKERR VecDuplicate(x, &f);
 
  114    CHKERR MatDuplicate(
A, MAT_DO_NOT_COPY_VALUES, &fdA);
 
  116    if (test_jacobian == PETSC_TRUE) {
 
  117      char testing_options[] =
 
  118          "-snes_test_jacobian -snes_test_jacobian_display " 
  119          "-snes_no_convergence_test -snes_atol 0 -snes_rtol 0 -snes_max_it 1 " 
  121      CHKERR PetscOptionsInsertString(NULL, testing_options);
 
  123      char testing_options[] = 
"-snes_no_convergence_test -snes_atol 0 " 
  124                               "-snes_rtol 0 -snes_max_it 1 -pc_type none";
 
  125      CHKERR PetscOptionsInsertString(NULL, testing_options);
 
  129    CHKERR SNESCreate(PETSC_COMM_WORLD, &snes);
 
  134    CHKERR SNESSetFromOptions(snes);
 
  136    CHKERR SNESSolve(snes, NULL, x);
 
  138    if (test_jacobian == PETSC_FALSE) {
 
  140      CHKERR MatNorm(
A, NORM_INFINITY, &nrm_A0);
 
  142      char testing_options_fd[] = 
"-snes_fd";
 
  143      CHKERR PetscOptionsInsertString(NULL, testing_options_fd);
 
  147      CHKERR SNESSetFromOptions(snes);
 
  149      CHKERR SNESSolve(snes, NULL, x);
 
  150      CHKERR MatAXPY(
A, -1, fdA, SUBSET_NONZERO_PATTERN);
 
  153      CHKERR MatNorm(
A, NORM_INFINITY, &nrm_A);
 
  154      PetscPrintf(PETSC_COMM_WORLD, 
"Matrix norms %3.4e %3.4e\n", nrm_A,
 
  158      const double tol = 1e-5;
 
  161                "Difference between hand-calculated tangent matrix and finite " 
  162                "difference matrix is too big");
 
  170    CHKERR SNESDestroy(&snes);
 
 
#define CATCH_ERRORS
Catch errors.
@ AINSWORTH_LEGENDRE_BASE
Ainsworth Cole (Legendre) approx. base .
@ MOFEM_ATOM_TEST_INVALID
#define CHKERR
Inline error check.
PetscErrorCode DMMoFEMSNESSetFunction(DM dm, const char fe_name[], MoFEM::FEMethod *method, MoFEM::BasicMethod *pre_only, MoFEM::BasicMethod *post_only)
set SNES residual evaluation function
PetscErrorCode DMoFEMMeshToLocalVector(DM dm, Vec l, InsertMode mode, ScatterMode scatter_mode)
set local (or ghosted) vector values on mesh for partition only
PetscErrorCode DMMoFEMSNESSetJacobian(DM dm, const char fe_name[], MoFEM::FEMethod *method, MoFEM::BasicMethod *pre_only, MoFEM::BasicMethod *post_only)
set SNES Jacobian evaluation function
PetscErrorCode DMRegister_MoFEM(const char sname[])
Register MoFEM problem.
PetscErrorCode DMMoFEMGetSnesCtx(DM dm, MoFEM::SnesCtx **snes_ctx)
get MoFEM::SnesCtx data structure
virtual MoFEMErrorCode get_finite_element_entities_by_dimension(const std::string name, int dim, Range &ents) const =0
get entities in the finite element by dimension
virtual MoFEMErrorCode loop_dofs(const Problem *problem_ptr, const std::string &field_name, RowColData rc, DofMethod &method, int lower_rank, int upper_rank, int verb=DEFAULT_VERBOSITY)=0
Make a loop over dofs.
implementation of Data Operators for Forces and Sources
PetscErrorCode SnesMat(SNES snes, Vec x, Mat A, Mat B, void *ctx)
This is MoFEM implementation for the left hand side (tangent matrix) evaluation in SNES solver.
PetscErrorCode SnesRhs(SNES snes, Vec x, Vec f, void *ctx)
This is MoFEM implementation for the right hand side (residual vector) evaluation in SNES solver.
PetscErrorCode PetscOptionsGetBool(PetscOptions *, const char pre[], const char name[], PetscBool *bval, PetscBool *set)
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.
Projection of edge entities with one mid-node on hierarchical basis.
Simple interface for fast problem set-up.
MoFEMErrorCode addDomainField(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_ZERO, int verb=-1)
Add field on domain.
MoFEMErrorCode loadFile(const std::string options, const std::string mesh_file_name, LoadFileFunc loadFunc=defaultLoadFileFunc)
Load mesh file.
MoFEMErrorCode getOptions()
get options
MoFEMErrorCode getDM(DM *dm)
Get DM.
MoFEMErrorCode setFieldOrder(const std::string field_name, const int order, const Range *ents=NULL)
Set field order.
MoFEMErrorCode setUp(const PetscBool is_partitioned=PETSC_TRUE)
Setup problem.
const std::string getDomainFEName() const
Get the Domain FE Name.
Interface for nonlinear (SNES) solver.
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.
Volume finite element base.
data for calculation heat conductivity and heat capacity elements
Set integration rule to volume elements.
int operator()(int, int, int) const