v0.13.2
Loading...
Searching...
No Matches
Functions | Variables
activate_deactivate_dofs.cpp File Reference
#include <MoFEM.hpp>

Go to the source code of this file.

Functions

int main (int argc, char *argv[])
 

Variables

static char help [] = "...\n\n"
 

Function Documentation

◆ main()

int main ( int  argc,
char *  argv[] 
)

Definition at line 15 of file activate_deactivate_dofs.cpp.

15 {
16 MoFEM::Core::Initialize(&argc, &argv, (char *)0, help);
17
18 try {
19
20 moab::Core mb_instance;
21 moab::Interface &moab = mb_instance;
22 int rank;
23 MPI_Comm_rank(PETSC_COMM_WORLD, &rank);
24
25 PetscBool flg = PETSC_TRUE;
26 char mesh_file_name[255];
27#if PETSC_VERSION_GE(3, 6, 4)
28 CHKERR PetscOptionsGetString(PETSC_NULL, "", "-my_file", mesh_file_name,
29 255, &flg);
30#else
31 CHKERR PetscOptionsGetString(PETSC_NULL, PETSC_NULL, "-my_file",
32 mesh_file_name, 255, &flg);
33#endif
34 if (flg != PETSC_TRUE) {
35 SETERRQ(PETSC_COMM_SELF, 1, "*** ERROR -my_file (MESH FILE NEEDED)");
36 }
37
38 const char *option;
39 option = "";
40 CHKERR moab.load_file(mesh_file_name, 0, option);
42
43 // Create MoFEM (Joseph) database
44 MoFEM::Core core(moab);
45 MoFEM::Interface &m_field = core;
46
47 // set entitities bit level
48 BitRefLevel bit_level0;
49 bit_level0.set(0);
50 EntityHandle meshset_level0;
51 CHKERR moab.create_meshset(MESHSET_SET, meshset_level0);
53 CHKERR m_field.getInterface<BitRefManager>()->setBitRefLevelByDim(
54 0, 3, bit_level0);
55
56 // Fields
57 CHKERR m_field.add_field("F1", L2, AINSWORTH_LEGENDRE_BASE, 1);
59
60 // meshset consisting all entities in mesh
61 EntityHandle root_set = moab.get_root_set();
62 // add entities to field
63 CHKERR m_field.add_ents_to_field_by_type(root_set, MBTET, "F1");
64 CHKERR m_field.add_ents_to_field_by_type(root_set, MBTET, "F2");
65
66 // set app. order
67 // see Hierarchic Finite Element Bases on Unstructured Tetrahedral Meshes
68 // (Mark Ainsworth & Joe Coyle)
69 int order = 4;
70 CHKERR m_field.set_field_order(root_set, MBTET, "F1", order - 1, 2);
71 CHKERR m_field.set_field_order(root_set, MBTET, "F2", order, 2);
72 CHKERR m_field.set_field_order(root_set, MBTRI, "F2", order, 2);
73
74 CHKERR m_field.build_fields();
75
76 order = 2;
77 CHKERR m_field.set_field_order(root_set, MBTET, "F1", order - 1, 2);
78 CHKERR m_field.set_field_order(root_set, MBTET, "F2", order, 2);
79 CHKERR m_field.set_field_order(root_set, MBTRI, "F2", order, 2);
80
82 CHKERR m_field.build_fields();
83
84 auto dofs_ptr = m_field.get_dofs();
85 const unsigned int expected_size = 300;
86 if (dofs_ptr->size() != expected_size) {
87 SETERRQ2(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
88 "Data inconsistency, should %d dofs but is %d", expected_size,
89 dofs_ptr->size());
90 }
91 }
93
94 // finish work cleaning memory, getting statistics, ect.
96
97 return 0;
98}
static char help[]
#define CATCH_ERRORS
Catch errors.
Definition: definitions.h:372
@ AINSWORTH_LEGENDRE_BASE
Ainsworth Cole (Legendre) approx. base .
Definition: definitions.h:60
@ L2
field with C-1 continuity
Definition: definitions.h:88
@ HDIV
field with continuous normal traction
Definition: definitions.h:87
#define CHKERRG(n)
Check error code of MoFEM/MOAB/PETSc function.
Definition: definitions.h:483
@ MOFEM_DATA_INCONSISTENCY
Definition: definitions.h:31
#define CHKERR
Inline error check.
Definition: definitions.h:535
virtual const DofEntity_multiIndex * get_dofs() const =0
Get the dofs object.
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 clear_inactive_dofs(int verb=DEFAULT_VERBOSITY)=0
char mesh_file_name[255]
static MoFEMErrorCodeGeneric< moab::ErrorCode > rval
Definition: Exceptions.hpp:74
std::bitset< BITREFLEVEL_SIZE > BitRefLevel
Bit structure attached to each entity identifying to what mesh entity is attached.
Definition: Types.hpp:40
PetscErrorCode PetscOptionsGetString(PetscOptions *, const char pre[], const char name[], char str[], size_t size, PetscBool *set)
Managing BitRefLevels.
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.
Core (interface) class.
Definition: Core.hpp:82
static MoFEMErrorCode Initialize(int *argc, char ***args, const char file[], const char help[])
Initializes the MoFEM database PETSc, MOAB and MPI.
Definition: Core.cpp:72
static MoFEMErrorCode Finalize()
Checks for options to be called at the conclusion of the program.
Definition: Core.cpp:112
Deprecated interface functions.
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface refernce to pointer of interface.

Variable Documentation

◆ help

char help[] = "...\n\n"
static
Examples
add_blockset.cpp, add_cubit_meshsets.cpp, analytical_nonlinear_poisson.cpp, analytical_poisson.cpp, analytical_poisson_field_split.cpp, approx_sphere.cpp, bernstein_bezier_generate_base.cpp, bone_adaptation.cpp, boundary_marker.cpp, build_large_problem.cpp, build_problems.cpp, cell_forces.cpp, child_and_parent.cpp, contact.cpp, continuity_check_on_contact_prism_side_ele.cpp, continuity_check_on_skeleton_3d.cpp, continuity_check_on_skeleton_with_simple_2d_for_h1.cpp, continuity_check_on_skeleton_with_simple_2d_for_hcurl.cpp, continuity_check_on_skeleton_with_simple_2d_for_hdiv.cpp, cubit_bc_test.cpp, delete_ho_nodes.cpp, dm_build_partitioned_mesh.cpp, dm_create_subdm.cpp, dm_partitioned_no_field.cpp, edge_and_bubble_shape_functions_on_quad.cpp, eigen_elastic.cpp, elasticity.cpp, elasticity_mixed_formulation.cpp, ep.cpp, field_blas.cpp, field_evaluator.cpp, field_to_vertices.cpp, forces_and_sources_testing_edge_element.cpp, forces_and_sources_testing_flat_prism_element.cpp, forces_and_sources_testing_users_base.cpp, free_surface.cpp, gauss_points_on_outer_product.cpp, hanging_node_approx.cpp, hcurl_check_approx_in_2d.cpp, hcurl_curl_operator.cpp, hcurl_divergence_operator_2d.cpp, hdiv_divergence_operator.cpp, heat_equation.cpp, heat_method.cpp, hello_world.cpp, helmholtz.cpp, hertz_surface.cpp, higher_derivatives.cpp, level_set.cpp, log.cpp, loop_entities.cpp, lorentz_force.cpp, magnetostatic.cpp, matrix_function.cpp, mesh_cut.cpp, mesh_insert_interface_atom.cpp, mesh_smoothing.cpp, meshset_to_vtk.cpp, minimal_surface_area.cpp, mixed_poisson.cpp, mortar_contact.cpp, mortar_contact_thermal.cpp, navier_stokes.cpp, node_merge.cpp, nonlinear_dynamics.cpp, nonlinear_elastic.cpp, operators_tests.cpp, partition_mesh.cpp, petsc_smart_ptr_objects.cpp, phase.cpp, photon_diffusion.cpp, plastic.cpp, plate.cpp, plot_base.cpp, poisson_2d_dis_galerkin.cpp, poisson_2d_homogeneous.cpp, poisson_3d_homogeneous.cpp, prism_elements_from_surface.cpp, prism_polynomial_approximation.cpp, quad_polynomial_approximation.cpp, reaction_diffusion.cpp, remove_entities_from_problem.cpp, remove_entities_from_problem_not_partitioned.cpp, scalar_check_approximation.cpp, shallow_wave.cpp, simple_contact.cpp, simple_contact_thermal.cpp, simple_elasticity.cpp, simple_interface.cpp, simple_l2_only.cpp, split_sideset.cpp, test_cache_on_entities.cpp, test_jacobian_of_simple_contact_element.cpp, testing_jacobian_of_hook_element.cpp, testing_jacobian_of_hook_scaled_with_density_element.cpp, thermo_elastic.cpp, unsaturated_transport.cpp, wave_equation.cpp, and wavy_surface.cpp.

Definition at line 13 of file activate_deactivate_dofs.cpp.