14 {
15
17
18 try {
19
20 enum spaces { H1TRI, HCURLTRI,
LASTOP };
21
22 const char *list_spaces[] = {"h1tri", "hcurltri"};
23
24 PetscBool flg;
25 PetscInt choice_value = H1TRI;
27 &choice_value, &flg);
28
29 if (flg != PETSC_TRUE) {
31 }
32
34 if (choice_value == H1TRI) {
36 } else if (choice_value == HCURLTRI) {
38 }
39
40
41 enum bases { AINSWORTH, DEMKOWICZ, LASBASETOP };
42
43 const char *list_bases[] = {"ainsworth", "demkowicz"};
44
45 PetscInt choice_base_value = AINSWORTH;
47 LASBASETOP, &choice_base_value, &flg);
48
49 if (flg != PETSC_TRUE) {
51 }
52
54 if (choice_base_value == AINSWORTH) {
56 } else if (choice_base_value == DEMKOWICZ) {
58 }
59
60 moab::Core mb_instance;
61 moab::Interface &moab = mb_instance;
62 int rank;
63 MPI_Comm_rank(PETSC_COMM_WORLD, &rank);
64
65
66 double tri_coords[] = {0, 0, 0,
67
68 0.5, 0, 0,
69
70 0, 2., 0};
72 for (int nn = 0; nn < 3; nn++) {
73 CHKERR moab.create_vertex(&tri_coords[3 * nn], nodes[nn]);
74 }
76 CHKERR moab.create_element(MBTRI, nodes, 3, tri);
77
78
80 CHKERR moab.get_adjacencies(&tri, 1, 1,
true, adj);
81
82
85
86
88 bit_level0.set(0);
90 0, 2, bit_level0);
91
92
94
95
97
98
102
103
105
106
108
109
111
112
114
116
117
119 "TRI_FE");
120
121
127 }
128 if (space ==
HCURL) {
131 }
132
133
135
136
138
139
141
142
145
147
148
151
152
154
155 typedef tee_device<std::ostream, std::ofstream>
TeeDevice;
157
158 std::ofstream ofs("forces_and_sources_checking_derivatives.txt");
161
162 struct OpCheckingDerivatives
163 : public FaceElementForcesAndSourcesCore::UserDataOperator {
164
166 OpCheckingDerivatives(
TeeStream &my_split)
169 mySplit(my_split) {}
170
174
177 mySplit <<
"type " <<
type <<
" side " << side << endl;
178
180
181
182
183
184 const int nb_dofs = data.
getN().size2();
185 for (
int dd = 0;
dd != nb_dofs;
dd++) {
186 const double dksi =
188 const double deta =
190 mySplit << "DKsi " << dksi << std::endl;
191 mySplit << "DEta " << deta << std::endl;
192 mySplit <<
"diffN " << data.
getDiffN()(4, 2 *
dd + 0) << std::endl;
193 mySplit <<
"diffN " << data.
getDiffN()(4, 2 *
dd + 1) << std::endl;
196 "H1 inconsistent dKsi derivative");
197 }
200 "H1 inconsistent dEta derivative");
201 }
202 }
203 }
204
206
219
220
221
222
227
231
232 const int nb_dofs = data.
getN().size2() / 3;
233 for (
int dd = 0;
dd != nb_dofs;
dd++) {
234
235 mySplit << "MoFEM " << diff_base(0, 0) << " " << diff_base(1, 0)
236 << " " << diff_base(2, 0) << endl;
237 mySplit << "MoFEM " << diff_base(0, 1) << " " << diff_base(1, 1)
238 << " " << diff_base(2, 1) << endl;
239
241 dksi(
i) = (base_ksi_p(
i) - base_ksi_m(
i)) / (
eps);
243 deta(
i) = (base_eta_p(
i) - base_eta_m(
i)) / (4 *
eps);
244 mySplit << "Finite difference dKsi " << dksi(0) << " " << dksi(1)
245 << " " << dksi(2) << endl;
246 mySplit << "Finite difference dEta " << deta(0) << " " << deta(1)
247 << " " << deta(2) << endl;
248
249 dksi(
i) -= diff_base(
i,
N0);
250 deta(
i) -= diff_base(
i,
N1);
252
254 "%s inconsistent dKsi derivative for type %d",
256 type);
257 } else {
258 mySplit << "OK" << std::endl;
259 }
261
263 "%s inconsistent dEta derivative for type %d",
265 type);
266 } else {
267 mySplit << "OK" << std::endl;
268 }
269
270 ++base_ksi_m;
271 ++base_ksi_p;
272 ++base_eta_m;
273 ++base_eta_p;
274 ++diff_base;
275 }
276 }
277
278 mySplit << endl;
279
281 }
282 };
283
285
289
292
295
296 gaussPts.resize(3, 5);
297 gaussPts.clear();
298
303
308
311
312 for (unsigned int ii = 0; ii != gaussPts.size2(); ii++) {
314 }
315
316
317
319 }
320 };
321
322 MyFE tri_fe(m_field);
323
325 tri_fe.getOpPtrVector().push_back(new OpCheckingDerivatives(my_split));
327
328 }
330
332}
ForcesAndSourcesCore::UserDataOperator UserDataOperator
static const double eps_diff
#define CATCH_ERRORS
Catch errors.
FieldApproximationBase
approximation base
@ AINSWORTH_LEGENDRE_BASE
Ainsworth Cole (Legendre) approx. base .
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
FieldSpace
approximation spaces
@ LASTSPACE
FieldSpace in [ 0, LASTSPACE )
@ HCURL
field with continuous tangents
static const char *const FieldSpaceNames[]
#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 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
FTensor::Index< 'i', SPACE_DIM > i
const Tensor2_symmetric_Expr< const ddTensor0< T, Dim, i, j >, typename promote< T, double >::V, Dim, i, j > dd(const Tensor0< T * > &a, const Index< i, Dim > index1, const Index< j, Dim > index2, const Tensor1< int, Dim > &d_ijk, const Tensor1< double, Dim > &d_xyz)
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
std::bitset< BITREFLEVEL_SIZE > BitRefLevel
Bit structure attached to each entity identifying to what mesh entity is attached.
PetscErrorCode PetscOptionsGetEList(PetscOptions *, const char pre[], const char name[], const char *const *list, PetscInt next, PetscInt *value, PetscBool *set)
Add operators pushing bases from local to physical configuration.
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 & getDiffN(const FieldApproximationBase base)
get derivatives of base functions
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
const VectorDofs & getFieldDofs() const
get dofs data stature FEDofEntity
virtual MoFEMErrorCode setGaussPts(int order_row, int order_col, int order_data)
set user specific integration rule
virtual int getRule(int order_row, int order_col, int order_data)
another variant of getRule
MatrixDouble gaussPts
Matrix of integration points.
Problem manager is used to build and partition problems.
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface refernce to pointer of interface.