109 const char *list_bases[] = {
"ainsworth",
"ainsworth_labatto",
"demkowicz",
112 PetscInt choice_base_value = AINSWORTH;
114 LASBASETOP, &choice_base_value, &flg);
116 if (flg != PETSC_TRUE)
119 if (choice_base_value == AINSWORTH)
121 if (choice_base_value == AINSWORTH_LOBATTO)
123 else if (choice_base_value == DEMKOWICZ)
125 else if (choice_base_value == BERNSTEIN)
128 enum spaces { H1SPACE, L2SPACE, LASBASETSPACE };
129 const char *list_spaces[] = {
"h1",
"l2"};
130 PetscInt choice_space_value = H1SPACE;
132 LASBASETSPACE, &choice_space_value, &flg);
133 if (flg != PETSC_TRUE)
136 if (choice_space_value == H1SPACE)
138 else if (choice_space_value == L2SPACE)
144 std::array<double, 12> one_quad_coords = {0, 0, 0,
152 std::array<EntityHandle, 4> one_quad_nodes;
153 for (
int n = 0;
n != 4; ++
n)
154 CHKERR moab.create_vertex(&one_quad_coords[3 *
n], one_quad_nodes[
n]);
155 EntityHandle one_quad;
156 CHKERR moab.create_element(MBQUAD, one_quad_nodes.data(), 4, one_quad);
157 Range one_quad_range;
158 one_quad_range.insert(one_quad);
159 Range one_quad_adj_ents;
160 CHKERR moab.get_adjacencies(one_quad_range, 1,
true, one_quad_adj_ents,
161 moab::Interface::UNION);
214 ->createMPIAIJWithArrays<PetscGlobalIdx_mi_tag>(
"TEST_PROBLEM", A);
222 auto rule = [&](
int,
int,
int p) {
return 2 * (
p + 1); };
224 auto assemble_matrices_and_vectors = [&]() {
227 fe.getRuleHook = rule;
233 fe.getOpPtrVector().push_back(
new QuadOpRhs(F));
234 fe.getOpPtrVector().push_back(
new QuadOpLhs(A));
238 CHKERR VecAssemblyBegin(F);
240 CHKERR MatAssemblyBegin(A, MAT_FINAL_ASSEMBLY);
241 CHKERR MatAssemblyEnd(A, MAT_FINAL_ASSEMBLY);
245 auto solve_problem = [&] {
247 auto solver =
createKSP(PETSC_COMM_WORLD);
248 CHKERR KSPSetOperators(solver, A, A);
249 CHKERR KSPSetFromOptions(solver);
252 CHKERR VecGhostUpdateBegin(
D, INSERT_VALUES, SCATTER_FORWARD);
253 CHKERR VecGhostUpdateEnd(
D, INSERT_VALUES, SCATTER_FORWARD);
255 "TEST_PROBLEM",
COL,
D, INSERT_VALUES, SCATTER_REVERSE);
259 auto check_solution = [&] {
262 fe.getRuleHook = rule;
263 boost::shared_ptr<VectorDouble> field_vals_ptr(
new VectorDouble());
264 boost::shared_ptr<MatrixDouble> diff_field_vals_ptr(
new MatrixDouble());
266 fe.getOpPtrVector().push_back(
273 "FIELD1", diff_field_vals_ptr, space ==
L2 ? MBQUAD : MBVERTEX));
274 fe.getOpPtrVector().push_back(
275 new QuadOpCheck(field_vals_ptr, diff_field_vals_ptr));
280 CHKERR assemble_matrices_and_vectors();
#define CATCH_ERRORS
Catch errors.
FieldApproximationBase
approximation base
@ AINSWORTH_LEGENDRE_BASE
Ainsworth Cole (Legendre) approx. base .
@ AINSWORTH_BERNSTEIN_BEZIER_BASE
FieldSpace
approximation spaces
@ L2
field with C-1 continuity
#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.
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 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 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_col(const std::string &fe_name, const std::string &name_row)=0
set field col 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.
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 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
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
ublas::vector< double, DoubleAllocator > VectorDouble
std::bitset< BITREFLEVEL_SIZE > BitRefLevel
Bit structure attached to each entity identifying to what mesh entity is attached.
ublas::matrix< double, ublas::row_major, DoubleAllocator > MatrixDouble
OpCalculateInvJacForFaceImpl< 2 > OpCalculateInvJacForFace
PetscErrorCode PetscOptionsGetEList(PetscOptions *, const char pre[], const char name[], const char *const *list, PetscInt next, PetscInt *value, PetscBool *set)
DeprecatedCoreInterface Interface
const double D
diffusivity
static constexpr int approx_order
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.
DEPRECATED MoFEMErrorCode loop_finite_elements(const Problem *problem_ptr, const std::string &fe_name, FEMethod &method, int lower_rank, int upper_rank, MoFEMTypes bh, int verb=DEFAULT_VERBOSITY)
Matrix manager is used to build and partition problems.
Get field gradients at integration pts for scalar filed rank 0, i.e. vector field.
Get value at integration points for scalar field.
Modify integration weights on face to take in account higher-order geometry.
Problem manager is used to build and partition problems.
MoFEMErrorCode getInterface(const MOFEMuuid &uuid, IFACE *&iface) const
Get interface by uuid and return reference to pointer of interface.
Vector manager is used to create vectors \mofem_vectors.