14 {
15
17
18 try {
19
20
21 enum spaces { H1TET, HDIVTET, HCURLTET, LASTSPACEOP };
22
23 const char *list_spaces[] = {"h1tet", "hdivtet", "hcurltet"};
24
25 PetscBool flg;
26 PetscInt choise_space_value = H1TET;
28 LASTSPACEOP, &choise_space_value, &flg);
29
30 if (flg != PETSC_TRUE) {
32 }
33
35 if (choise_space_value == H1TET) {
37 } else if (choise_space_value == HDIVTET) {
39 } else if (choise_space_value == HCURLTET) {
41 }
42
43
44 enum bases { AINSWORTH, DEMKOWICZ, LASBASETOP };
45
46 const char *list_bases[] = {"ainsworth", "demkowicz"};
47
48 PetscInt choice_base_value = AINSWORTH;
50 LASBASETOP, &choice_base_value, &flg);
51
52 if (flg != PETSC_TRUE) {
54 }
55
57 if (choice_base_value == AINSWORTH) {
59 } else if (choice_base_value == DEMKOWICZ) {
61 }
62
63 moab::Core mb_instance;
64 moab::Interface &moab = mb_instance;
65 int rank;
66 MPI_Comm_rank(PETSC_COMM_WORLD, &rank);
67
68
69 double tet_coords[] = {0, 0, 0, 0.5, 0, 0, 0, 0.5, 0, 0, 0, 0.5};
71 for (int nn = 0; nn < 4; nn++) {
72 CHKERR moab.create_vertex(&tet_coords[3 * nn], nodes[nn]);
73 }
75 CHKERR moab.create_element(MBTET, nodes, 4, tet);
76
77
80
81
83 bit_level0.set(0);
85 0, 3, bit_level0);
86
87
88
90
91
93
94
98
99
100
102
103
104
106
107
109
110
111
113
115
116
119
120
121
128
129 }
130 if (space ==
HCURL) {
134
135 }
139 }
140
141
142
143
145
146
148
149
151
152
153
156
157
159
160
161
164
165
167
168 typedef tee_device<std::ostream, std::ofstream>
TeeDevice;
170
171 std::ofstream ofs("forces_and_sources_checking_derivatives.txt");
174
175 struct OpCheckingDerivatives
176 : public VolumeElementForcesAndSourcesCore::UserDataOperator {
177
179 OpCheckingDerivatives(
TeeStream &my_split)
182 mySplit(my_split) {}
183
187
190
191 mySplit <<
"Type " <<
type <<
" side " << side << endl;
192
194
195
196
197
198 const int nb_dofs = data.
getN().size2();
199 for (
int dd = 0;
dd != nb_dofs;
dd++) {
202 const double dzeta =
204 mySplit <<
"DKsi " << dksi - data.
getDiffN()(6, 3 *
dd + 0)
205 << std::endl;
206 mySplit <<
"DEta " << deta - data.
getDiffN()(6, 3 *
dd + 1)
207 << std::endl;
208 mySplit <<
"DZeta " << dzeta - data.
getDiffN()(6, 3 *
dd + 2)
209 << std::endl;
212 "H1 inconsistent dKsi derivative");
213 }
216 "H1 inconsistent dEta derivative");
217 }
220 "H1 inconsistent dZeta derivative");
221 }
222 }
223 }
224
227
229 &data.
getN()(0, 0), &data.
getN()(0, 1), &data.
getN()(0, 2), 3);
231 &data.
getN()(1, 0), &data.
getN()(1, 1), &data.
getN()(1, 2), 3);
233 &data.
getN()(2, 0), &data.
getN()(2, 1), &data.
getN()(2, 2), 3);
235 &data.
getN()(3, 0), &data.
getN()(3, 1), &data.
getN()(3, 2), 3);
237 &data.
getN()(4, 0), &data.
getN()(4, 1), &data.
getN()(4, 2), 3);
239 &data.
getN()(5, 0), &data.
getN()(5, 1), &data.
getN()(5, 2), 3);
240
247
252
253 const int nb_dofs = data.
getN().size2() / 3;
254 for (
int dd = 0;
dd != nb_dofs;
dd++) {
256 dksi(
i) = (base_ksi_p(
i) - base_ksi_m(
i)) /
eps;
258 deta(
i) = (base_eta_p(
i) - base_eta_m(
i)) /
eps;
260 dzeta(
i) = (base_zeta_p(
i) - base_zeta_m(
i)) /
eps;
261
262 dksi(
i) -= diff_base(
i,
N0);
263 deta(
i) -= diff_base(
i,
N1);
264 dzeta(
i) -= diff_base(
i,
N2);
265
266 mySplit << "dKsi " << dksi(0) << " " << dksi(1) << " " << dksi(2)
267 <<
" " << sqrt(dksi(
i) * dksi(
i)) << endl;
268 mySplit << "dEta " << deta(0) << " " << deta(1) << " " << deta(2)
269 <<
" " << sqrt(deta(
i) * deta(
i)) << endl;
270 mySplit << "dZeta " << dzeta(0) << " " << dzeta(1) << " "
271 << dzeta(2) <<
" " << sqrt(dzeta(
i) * dzeta(
i)) << endl;
272
275 "%s inconsistent dKsi derivative for type %d",
277 type);
278 }
281 "%s inconsistent dEta derivative for type %d",
283 type);
284 }
287 "%s inconsistent dZeta derivative for type %d",
289 type);
290 }
291
292 ++base_ksi_m;
293 ++base_ksi_p;
294 ++base_eta_m;
295 ++base_eta_p;
296 ++base_zeta_m;
297 ++base_zeta_p;
298 ++diff_base;
299 }
300 }
301
303 }
304 };
305
307
311
314
318
319 gaussPts.resize(4, 7);
320 gaussPts.clear();
321
328
335
342
346
347 for (unsigned int ii = 0; ii != gaussPts.size2(); ii++) {
349 }
350
351 cerr << gaussPts << endl;
352
354 }
355 };
356
357 MyFE tet_fe(m_field);
358
359 tet_fe.getOpPtrVector().push_back(new OpCheckingDerivatives(my_split));
361
362 }
364
366
367}
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
@ HDIV
field with continuous normal traction
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)
double zeta
Viscous hardening.
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.
Volume finite element base.