15 {
16
17
18
19
21
22 try {
23
24 moab::Core mb_instance;
25 moab::Interface& moab = mb_instance;
26 int rank;
27 MPI_Comm_rank(PETSC_COMM_WORLD,&rank);
28
29 PetscBool flg = PETSC_TRUE;
31 #if PETSC_VERSION_GE(3,6,4)
33 #else
35 #endif
36 if(flg != PETSC_TRUE) {
38 }
39
40
43
44 const char *option;
45 option = "";
47
48
50 bit_level0.set(0);
54
55
58
59
60
62
63
68
69
71
72
74
76
77
78
80
83
84
85
87
88
89
95
100
101
102
103
105
107
109
110
113
118
119 typedef tee_device<std::ostream, std::ofstream>
TeeDevice;
121
122 std::ofstream ofs("forces_and_sources_testing_ftensor.txt");
125
126 struct MyOp1: public VolumeElementForcesAndSourcesCore::UserDataOperator {
127
128 boost::shared_ptr<MatrixDouble> field1ValuesDataPtr;
129 boost::shared_ptr<VectorDouble> field2ValuesDataPtr;
130 boost::shared_ptr<MatrixDouble> grad1ValuesDataPtr;
131 boost::shared_ptr<MatrixDouble> grad2ValuesDataPtr;
133
134 MyOp1(
135 boost::shared_ptr<MatrixDouble> field1_values_data_ptr,
136 boost::shared_ptr<VectorDouble> field2_values_data_ptr,
137 boost::shared_ptr<MatrixDouble> grad1_values_data_ptr,
138 boost::shared_ptr<MatrixDouble> grad2_values_data_ptr,
140 char type
141 ):
143 field1ValuesDataPtr(field1_values_data_ptr),
144 field2ValuesDataPtr(field2_values_data_ptr),
145 grad1ValuesDataPtr(grad1_values_data_ptr),
146 grad2ValuesDataPtr(grad2_values_data_ptr),
147 my_split(_my_split) {}
148
149
151 int side,
155
157 const int nb_gauss_pts = data.
getN().size1();
158 const int nb_base_functions = data.
getN().size2();
159
162
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207 for(int gg = 0;gg!=nb_gauss_pts;gg++) {
208
209 for(int bb = 0;bb!=nb_base_functions;bb++) {
210
211 double base_val = base_function;
212
213 if(base_val!=data.
getN(gg)[bb]) {
215 }
216 ++base_function;
217
218 for(
int dd = 0;
dd<3;
dd++) {
219 if(diff_base(dd)!=data.
getDiffN()(gg,3*bb+dd)) {
220 SETERRQ2(
221 PETSC_COMM_SELF,
223 "Data inconsistency gg = %d bb = %d",
224 gg,
225 bb
226 );
227 }
228 }
229
230 t2(
I,
J) = diff_base(
I)*diff_base(
J);
231
233
234 for(int II = 0;II!=3;II++) {
235 for(int JJ = 0;JJ!=3;JJ++) {
236 if(t2(II,JJ)-mat(II,JJ)!=0) {
238 }
239 }
240 }
241
242
243 ++diff_base;
244
245 }
246
247
248
249
250
251
252 }
254 }
255
257 int row_side,int col_side,
261 ) {
263
264
265 const int nb_gauss_pts = row_data.
getN().size1();
266 const int nb_base_functions_row = row_data.
getN().size2();
267 const int nb_base_functions_col = col_data.
getN().size2();
268
272
276
279
280 for(int br = 0;br!=nb_base_functions_row;br++) {
283
284 for(int bc = 0;bc!=nb_base_functions_col;bc++) {
287
288 auto field1_values = getFTensor1FromMat<3>(*field1ValuesDataPtr);
290 auto grad1_values = getFTensor2FromMat<3,3>(*grad1ValuesDataPtr);
291 auto grad2_values = getFTensor1FromMat<3>(*grad2ValuesDataPtr);
292
293 for(int gg = 0;gg!=nb_gauss_pts;gg++) {
294
295
296 t2(
I,
J) = diff_base_row(
I)*diff_base_col(
J)*base_row*base_col;
297 t3(
I,
J,
K) = grad1_values(
I,
J)*field1_values(
K)*field2_values;
298 ++field1_values;
299 ++field2_values;
300 ++grad1_values;
301 ++grad2_values;
302 }
303 ++base_col;
304 ++diff_base_col;
305
306 }
307 ++base_row;
308 ++diff_base_row;
309
310 }
311
313 }
314
315 };
316
317 boost::shared_ptr<MatrixDouble> values1_at_gauss_pts_ptr =
319 boost::shared_ptr<VectorDouble> values2_at_gauss_pts_ptr =
321 boost::shared_ptr<MatrixDouble> grad1_at_gauss_pts_ptr =
323 boost::shared_ptr<MatrixDouble> grad2_at_gauss_pts_ptr =
325
327
328 fe1.getOpPtrVector().push_back(
330 fe1.getOpPtrVector().push_back(
333 "FIELD1", grad1_at_gauss_pts_ptr));
334 fe1.getOpPtrVector().push_back(
336
337 fe1.getOpPtrVector().push_back(
338 new MyOp1(
339 values1_at_gauss_pts_ptr,
340 values2_at_gauss_pts_ptr,
341 grad1_at_gauss_pts_ptr,
342 grad2_at_gauss_pts_ptr,
343 my_split,
344 ForcesAndSourcesCore::UserDataOperator::OPROW
345 )
346 );
347 fe1.getOpPtrVector().push_back(
348 new MyOp1(
349 values1_at_gauss_pts_ptr,
350 values2_at_gauss_pts_ptr,
351 grad1_at_gauss_pts_ptr,
352 grad2_at_gauss_pts_ptr,
353 my_split,
354 ForcesAndSourcesCore::UserDataOperator::OPROWCOL
355 )
356 );
357
359
360
363 }
364
366
367 return 0;
368
369}
ForcesAndSourcesCore::UserDataOperator UserDataOperator
@ AINSWORTH_LEGENDRE_BASE
Ainsworth Cole (Legendre) approx. base .
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define CHKERRG(n)
Check error code of MoFEM/MOAB/PETSc function.
@ MOFEM_DATA_INCONSISTENCY
#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
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)
static MoFEMErrorCodeGeneric< PetscErrorCode > ierr
static MoFEMErrorCodeGeneric< moab::ErrorCode > rval
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
UBlasMatrix< double > MatrixDouble
std::bitset< BITREFLEVEL_SIZE > BitRefLevel
Bit structure attached to each entity identifying to what mesh entity is attached.
UBlasVector< double > VectorDouble
MatrixShallowArrayAdaptor< double > MatrixAdaptor
Matrix adaptor.
static auto getFTensor0FromVec(ublas::vector< T, A > &data)
Get tensor rank 0 (scalar) form data vector.
PetscErrorCode PetscOptionsGetString(PetscOptions *, const char pre[], const char name[], char str[], size_t size, PetscBool *set)
constexpr IntegrationType I
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)
FTensor::Tensor1< FTensor::PackPtr< double *, Tensor_Dim >, Tensor_Dim > getFTensor1DiffN(const FieldApproximationBase base)
Get derivatives of base functions.
FTensor::Tensor0< FTensor::PackPtr< double *, 1 > > getFTensor0N(const FieldApproximationBase base)
Get base function as Tensor0.
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....
Get field gradients at integration pts for scalar filed rank 0, i.e. vector field.
Get value at integration points for scalar field.
Get field gradients at integration pts for scalar filed rank 0, i.e. vector field.
Get values at integration pts for tensor filed rank 1, i.e. vector field.
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.