v0.15.0
Loading...
Searching...
No Matches
Macros | Functions | Variables
homogenisation_disp_atom_test.cpp File Reference
#include <MoFEM.hpp>
#include <Projection10NodeCoordsOnField.hpp>
#include <petsctime.h>
#include <FEMethod_LowLevelStudent.hpp>
#include <FEMethod_UpLevelStudent.hpp>
#include <adolc/adolc.h>
#include <NonLinearElasticElement.hpp>
#include <Hooke.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/numeric/ublas/vector_proxy.hpp>
#include <boost/iostreams/tee.hpp>
#include <boost/iostreams/stream.hpp>
#include <fstream>
#include <iostream>
#include <MethodForForceScaling.hpp>
#include <TimeForceScale.hpp>
#include <BCs_RVELagrange_Disp.hpp>
#include <VolumeCalculation.hpp>
#include <boost/ptr_container/ptr_map.hpp>
#include <PostProcOnRefMesh.hpp>
#include <PostProcStresses.hpp>

Go to the source code of this file.

Macros

#define RND_EPS   1e-6
 

Functions

double roundn (double n)
 
int main (int argc, char *argv[])
 

Variables

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

Macro Definition Documentation

◆ RND_EPS

#define RND_EPS   1e-6

Definition at line 48 of file homogenisation_disp_atom_test.cpp.

Function Documentation

◆ main()

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

Definition at line 84 of file homogenisation_disp_atom_test.cpp.

84 {
85
86 MoFEM::Core::Initialize(&argc,&argv,(char *)0,help);
87
88 try {
89
90 moab::Core mb_instance;
91 moab::Interface& moab = mb_instance;
92 int rank;
93 MPI_Comm_rank(PETSC_COMM_WORLD,&rank);
94
95 //Reade parameters from line command
96 PetscBool flg = PETSC_TRUE;
97 char mesh_file_name[255];
98 ierr = PetscOptionsGetString(PETSC_NULL,"-my_file",mesh_file_name,255,&flg); CHKERRQ(ierr);
99 if(flg != PETSC_TRUE) {
100 SETERRQ(PETSC_COMM_SELF,1,"*** ERROR -my_file (MESH FILE NEEDED)");
101 }
102 PetscInt order;
103 ierr = PetscOptionsGetInt(PETSC_NULL,"-my_order",&order,&flg); CHKERRQ(ierr);
104 if(flg != PETSC_TRUE) {
105 order = 1;
106 }
107
108 //Read mesh to MOAB
109 const char *option;
110 option = "";//"PARALLEL=BCAST;";//;DEBUG_IO";
111 rval = moab.load_file(mesh_file_name, 0, option); CHKERRQ_MOAB(rval);
112 ParallelComm* pcomm = ParallelComm::get_pcomm(&moab,MYPCOMM_INDEX);
113 if(pcomm == NULL) pcomm = new ParallelComm(&moab,PETSC_COMM_WORLD);
114
115 //We need that for code profiling
116 PetscLogDouble t1,t2;
117 PetscLogDouble v1,v2;
118 ierr = PetscTime(&v1); CHKERRQ(ierr);
119 ierr = PetscGetCPUTime(&t1); CHKERRQ(ierr);
120
121 //Create MoFEM (Joseph) database
122 MoFEM::Core core(moab);
123 MoFEM::Interface& m_field = core;
124
125 //ref meshset ref level 0
126 ierr = m_field.seed_ref_level_3D(0,0); CHKERRQ(ierr);
127
128 // stl::bitset see for more details
129 BitRefLevel bit_level0;
130 bit_level0.set(0);
131 EntityHandle meshset_level0;
132 rval = moab.create_meshset(MESHSET_SET,meshset_level0); CHKERRQ_MOAB(rval);
133 ierr = m_field.seed_ref_level_3D(0,bit_level0); CHKERRQ(ierr);
134 ierr = m_field.get_entities_by_ref_level(bit_level0,BitRefLevel().set(),meshset_level0); CHKERRQ(ierr);
135
136 /***/
137 //Define problem
138
139 //Fields
140 int field_rank=3;
141 ierr = m_field.add_field("DISPLACEMENT",H1,AINSWORTH_LEGENDRE_BASE,field_rank,MB_TAG_SPARSE,MF_ZERO); CHKERRQ(ierr);
142 ierr = m_field.add_field("MESH_NODE_POSITIONS",H1,AINSWORTH_LEGENDRE_BASE,field_rank,MB_TAG_SPARSE,MF_ZERO); CHKERRQ(ierr);
143 ierr = m_field.add_field("LAGRANGE_MUL_DISP",H1,AINSWORTH_LEGENDRE_BASE,field_rank); CHKERRQ(ierr);
144
145 //Add entitities to the fields
146 //============================================================================================================
147 ierr = m_field.add_ents_to_field_by_type(0,MBTET,"DISPLACEMENT"); CHKERRQ(ierr);
148 ierr = m_field.add_ents_to_field_by_type(0,MBTET,"MESH_NODE_POSITIONS"); CHKERRQ(ierr);
149
150 Range SurfacesFaces;
151 ierr = m_field.get_cubit_msId_entities_by_dimension(103,SIDESET,2,SurfacesFaces,true); CHKERRQ(ierr);
152 ierr = PetscPrintf(PETSC_COMM_WORLD,"number of SideSet 103 = %d\n",SurfacesFaces.size()); CHKERRQ(ierr);
153
154 EntityHandle BoundFacesMeshset;
155 rval = moab.create_meshset(MESHSET_SET,BoundFacesMeshset); CHKERRQ_MOAB(rval);
156 rval = moab.add_entities(BoundFacesMeshset,SurfacesFaces); CHKERRQ_MOAB(rval);
157 ierr = m_field.seed_ref_level_MESHSET(BoundFacesMeshset,BitRefLevel().set()); CHKERRQ(ierr);
158 ierr = m_field.add_ents_to_field_by_type(BoundFacesMeshset,MBTRI,"LAGRANGE_MUL_DISP"); CHKERRQ(ierr);
159 //============================================================================================================
160
161 //set approximaiton order
162 //see Hierarchic Finite Element Bases on Unstructured Tetrahedral Meshes (Mark Ainsworth & Joe Coyle)
163 ierr = m_field.set_field_order(0,MBTET,"DISPLACEMENT",order); CHKERRQ(ierr);
164 ierr = m_field.set_field_order(0,MBTRI,"DISPLACEMENT",order); CHKERRQ(ierr);
165 ierr = m_field.set_field_order(0,MBEDGE,"DISPLACEMENT",order); CHKERRQ(ierr);
166 ierr = m_field.set_field_order(0,MBVERTEX,"DISPLACEMENT",1); CHKERRQ(ierr);
167
168 ierr = m_field.set_field_order(0,MBTET,"MESH_NODE_POSITIONS",2); CHKERRQ(ierr);
169 ierr = m_field.set_field_order(0,MBTRI,"MESH_NODE_POSITIONS",2); CHKERRQ(ierr);
170 ierr = m_field.set_field_order(0,MBEDGE,"MESH_NODE_POSITIONS",2); CHKERRQ(ierr);
171 ierr = m_field.set_field_order(0,MBVERTEX,"MESH_NODE_POSITIONS",1); CHKERRQ(ierr);
172
173 ierr = m_field.set_field_order(0,MBTRI,"LAGRANGE_MUL_DISP",order); CHKERRQ(ierr);
174 ierr = m_field.set_field_order(0,MBEDGE,"LAGRANGE_MUL_DISP",order); CHKERRQ(ierr);
175 ierr = m_field.set_field_order(0,MBVERTEX,"LAGRANGE_MUL_DISP",1); CHKERRQ(ierr);
176
177
178 //Define FE
179 //define eleatic element
180 boost::shared_ptr<Hooke<adouble> > hooke_adouble(new Hooke<adouble>);
181 boost::shared_ptr<Hooke<double> > hooke_double(new Hooke<double>);
182 NonlinearElasticElement elastic(m_field,2);
183 ierr = elastic.setBlocks(hooke_double,hooke_adouble); CHKERRQ(ierr);
184 ierr = elastic.addElement("ELASTIC","DISPLACEMENT"); CHKERRQ(ierr);
185 ierr = elastic.setOperators("DISPLACEMENT","MESH_NODE_POSITIONS",false,true); CHKERRQ(ierr);
186
187
188 BCs_RVELagrange_Disp lagrangian_element(m_field);
189 lagrangian_element.addLagrangiangElement("LAGRANGE_ELEM","DISPLACEMENT","LAGRANGE_MUL_DISP","MESH_NODE_POSITIONS");
190
191 //define problems
192 ierr = m_field.add_problem("ELASTIC_MECHANICS"); CHKERRQ(ierr);
193
194 //set finite elements for problem
195 ierr = m_field.modify_problem_add_finite_element("ELASTIC_MECHANICS","ELASTIC"); CHKERRQ(ierr);
196 ierr = m_field.modify_problem_add_finite_element("ELASTIC_MECHANICS","LAGRANGE_ELEM"); CHKERRQ(ierr);
197
198
199 //set refinement level for problem
200 ierr = m_field.modify_problem_ref_level_add_bit("ELASTIC_MECHANICS",bit_level0); CHKERRQ(ierr);
201
202 /***/
203 //Declare problem
204
205 /****/
206 //build database
207
208 //build field
209 ierr = m_field.build_fields(); CHKERRQ(ierr);
210 Projection10NodeCoordsOnField ent_method_material(m_field,"MESH_NODE_POSITIONS");
211 ierr = m_field.loop_dofs("MESH_NODE_POSITIONS",ent_method_material); CHKERRQ(ierr);
212
213 //build finite elemnts
214 ierr = m_field.build_finite_elements(); CHKERRQ(ierr);
215
216 //build adjacencies
217 ierr = m_field.build_adjacencies(bit_level0); CHKERRQ(ierr);
218
219 //build problem
220 ierr = m_field.build_problems(); CHKERRQ(ierr);
221
222
223 /****/
224 //mesh partitioning
225
226 //partition
227 ierr = m_field.partition_problem("ELASTIC_MECHANICS"); CHKERRQ(ierr);
228 ierr = m_field.partition_finite_elements("ELASTIC_MECHANICS"); CHKERRQ(ierr);
229 //what are ghost nodes, see Petsc Manual
230 ierr = m_field.partition_ghost_dofs("ELASTIC_MECHANICS"); CHKERRQ(ierr);
231
232 //print bcs
233 ierr = m_field.print_cubit_displacement_set(); CHKERRQ(ierr);
234 ierr = m_field.print_cubit_force_set(); CHKERRQ(ierr);
235 //print block sets with materials
236 ierr = m_field.print_cubit_materials_set(); CHKERRQ(ierr);
237
238 //create matrices (here F, D and Aij are matrices for the full problem)
239 vector<Vec> F(6);
240 ierr = m_field.VecCreateGhost("ELASTIC_MECHANICS",ROW,&F[0]); CHKERRQ(ierr);
241 for(int ii = 1;ii<6;ii++) {
242 ierr = VecDuplicate(F[0],&F[ii]); CHKERRQ(ierr);
243 }
244
245 Vec D;
246 ierr = m_field.VecCreateGhost("ELASTIC_MECHANICS",COL,&D); CHKERRQ(ierr);
247
248 Mat Aij;
249 ierr = m_field.MatCreateMPIAIJWithArrays("ELASTIC_MECHANICS",&Aij); CHKERRQ(ierr);
250
251 ierr = VecZeroEntries(D); CHKERRQ(ierr);
252 ierr = VecGhostUpdateBegin(D,INSERT_VALUES,SCATTER_FORWARD); CHKERRQ(ierr);
253 ierr = VecGhostUpdateEnd(D,INSERT_VALUES,SCATTER_FORWARD); CHKERRQ(ierr);
254 ierr = m_field.set_global_ghost_vector(
255 "ELASTIC_MECHANICS",ROW,D,INSERT_VALUES,SCATTER_REVERSE
256 ); CHKERRQ(ierr);
257
258 for(int ii = 0;ii<6;ii++) {
259 ierr = VecZeroEntries(F[ii]); CHKERRQ(ierr);
260 ierr = VecGhostUpdateBegin(F[ii],INSERT_VALUES,SCATTER_FORWARD); CHKERRQ(ierr);
261 ierr = VecGhostUpdateEnd(F[ii],INSERT_VALUES,SCATTER_FORWARD); CHKERRQ(ierr);
262 }
263 ierr = MatZeroEntries(Aij); CHKERRQ(ierr);
264
265 //Assemble F and Aij
266 elastic.getLoopFeLhs().snes_B = Aij;
267 ierr = m_field.loop_finite_elements("ELASTIC_MECHANICS","ELASTIC",elastic.getLoopFeLhs()); CHKERRQ(ierr);
268
269 lagrangian_element.setRVEBCsOperators("DISPLACEMENT","LAGRANGE_MUL_DISP","MESH_NODE_POSITIONS",Aij,F);
270 ierr = m_field.loop_finite_elements("ELASTIC_MECHANICS","LAGRANGE_ELEM",lagrangian_element.getLoopFeRVEBCLhs()); CHKERRQ(ierr);
271 cout<<"after lagrangian_element.getLoopFeRVEBCLhs "<<endl;
272 ierr = m_field.loop_finite_elements("ELASTIC_MECHANICS","LAGRANGE_ELEM",lagrangian_element.getLoopFeRVEBCRhs()); CHKERRQ(ierr);
273 cout<<"after lagrangian_element.getLoopFeRVEBCRhs "<<endl;
274//
275// //Matrix View
276// MatView(Aij,PETSC_VIEWER_DRAW_WORLD);//PETSC_VIEWER_STDOUT_WORLD);
277// std::string wait;
278// std::cin >> wait;
279
280 ierr = MatAssemblyBegin(Aij,MAT_FINAL_ASSEMBLY); CHKERRQ(ierr);
281 ierr = MatAssemblyEnd(Aij,MAT_FINAL_ASSEMBLY); CHKERRQ(ierr);
282
283 for(int ii = 0;ii<6;ii++) {
284 ierr = VecGhostUpdateBegin(F[ii],ADD_VALUES,SCATTER_REVERSE); CHKERRQ(ierr);
285 ierr = VecGhostUpdateEnd(F[ii],ADD_VALUES,SCATTER_REVERSE); CHKERRQ(ierr);
286 ierr = VecAssemblyBegin(F[ii]); CHKERRQ(ierr);
287 ierr = VecAssemblyEnd(F[ii]); CHKERRQ(ierr);
288 }
289
290// ierr = VecView(F,PETSC_VIEWER_STDOUT_WORLD); CHKERRQ(ierr);
291// ierr = MatView(Aij,PETSC_VIEWER_STDOUT_WORLD); CHKERRQ(ierr);
292
293
294 // Volume calculation
295 //==============================================================================================================================
296 VolumeElementForcesAndSourcesCore vol_elem(m_field);
297 Vec volume_vec;
298 int volume_vec_ghost[] = { 0 };
299 ierr = VecCreateGhost(
300 PETSC_COMM_WORLD,(!m_field.get_comm_rank())?1:0,1,1,volume_vec_ghost,&volume_vec
301 ); CHKERRQ(ierr);
302 ierr = VecZeroEntries(volume_vec); CHKERRQ(ierr);
303 vol_elem.getOpPtrVector().push_back(new VolumeCalculation("DISPLACEMENT",volume_vec));
304
305 ierr = m_field.loop_finite_elements("ELASTIC_MECHANICS","ELASTIC", vol_elem); CHKERRQ(ierr);
306
307 ierr = VecAssemblyBegin(volume_vec); CHKERRQ(ierr);
308 ierr = VecAssemblyEnd(volume_vec); CHKERRQ(ierr);
309 double rve_volume;
310 ierr = VecSum(volume_vec,&rve_volume); CHKERRQ(ierr);
311
312 ierr = VecView(volume_vec,PETSC_VIEWER_STDOUT_WORLD); CHKERRQ(ierr);
313 ierr = PetscPrintf(PETSC_COMM_WORLD,"RVE Volume %3.2g\n",rve_volume); CHKERRQ(ierr);
314 ierr = VecDestroy(&volume_vec);
315
316 //==============================================================================================================================
317 //Post processing
318 //==============================================================================================================================
320 bool doPreProcess;
321 bool doPostProcess;
324 doPreProcess(true),
325 doPostProcess(true)
326 {}
327 void setDoPreProcess() { doPreProcess = true; }
328 void unSetDoPreProcess() { doPreProcess = false; }
329 void setDoPostProcess() { doPostProcess = true; }
330 void unSetDoPostProcess() { doPostProcess = false; }
331
332
333
334 PetscErrorCode preProcess() {
335 PetscFunctionBegin;
336 if(doPreProcess) {
338 }
339 PetscFunctionReturn(0);
340 }
341 PetscErrorCode postProcess() {
342 PetscFunctionBegin;
343 if(doPostProcess) {
345 }
346 PetscFunctionReturn(0);
347 }
348 };
349
350 MyPostProc post_proc(m_field);
351
352 ierr = post_proc.generateReferenceElementMesh(); CHKERRQ(ierr);
353 ierr = post_proc.addFieldValuesPostProc("DISPLACEMENT"); CHKERRQ(ierr);
354 ierr = post_proc.addFieldValuesGradientPostProc("DISPLACEMENT"); CHKERRQ(ierr);
355 ierr = post_proc.addFieldValuesPostProc("MESH_NODE_POSITIONS"); CHKERRQ(ierr);
356 ierr = post_proc.addFieldValuesGradientPostProc("MESH_NODE_POSITIONS"); CHKERRQ(ierr);
357
358 for(
359 map<int,NonlinearElasticElement::BlockData>::iterator sit = elastic.setOfBlocks.begin();
360 sit != elastic.setOfBlocks.end(); sit++
361 ) {
362 post_proc.getOpPtrVector().push_back(
363 new PostPorcStress(
364 post_proc.postProcMesh,
365 post_proc.mapGaussPts,
366 "DISPLACEMENT",
367 sit->second,
368 post_proc.commonData,
369 false
370 )
371 );
372 }
373 ierr = VecGhostUpdateBegin(D,INSERT_VALUES,SCATTER_FORWARD); CHKERRQ(ierr);
374 ierr = VecGhostUpdateEnd(D,INSERT_VALUES,SCATTER_FORWARD); CHKERRQ(ierr);
375 ierr = m_field.set_global_ghost_vector(
376 "ELASTIC_MECHANICS",ROW,D,INSERT_VALUES,SCATTER_REVERSE
377 ); CHKERRQ(ierr);
378
379 //==============================================================================================================================
380
381 //Solver
382 KSP solver;
383 ierr = KSPCreate(PETSC_COMM_WORLD,&solver); CHKERRQ(ierr);
384 ierr = KSPSetOperators(solver,Aij,Aij); CHKERRQ(ierr);
385 ierr = KSPSetFromOptions(solver); CHKERRQ(ierr);
386 ierr = KSPSetUp(solver); CHKERRQ(ierr);
387
388 MatrixDouble Dmat;
389 Dmat.resize(6,6);
390 Dmat.clear();
391
392 //calculate honmogenised stress
393 //create a vector for 6 components of homogenized stress
394 Vec stress_homo;
395 int stress_homo_ghost[] = { 0,1,2,3,4,5,6 };
396 ierr = VecCreateGhost(
397 PETSC_COMM_WORLD,(!m_field.get_comm_rank())?6:0,6,6,stress_homo_ghost,&stress_homo
398 ); CHKERRQ(ierr);
399
400 lagrangian_element.setRVEBCsHomoStressOperators("DISPLACEMENT","LAGRANGE_MUL_DISP","MESH_NODE_POSITIONS",stress_homo);
401
402 PetscScalar *avec;
403 ierr = VecGetArray(stress_homo,&avec); CHKERRQ(ierr);
404 for(int ii = 0;ii<6;ii++) {
405 ierr = VecZeroEntries(D); CHKERRQ(ierr);
406 ierr = KSPSolve(solver,F[ii],D); CHKERRQ(ierr);
407 ierr = VecGhostUpdateBegin(D,INSERT_VALUES,SCATTER_FORWARD); CHKERRQ(ierr);
408 ierr = VecGhostUpdateEnd(D,INSERT_VALUES,SCATTER_FORWARD); CHKERRQ(ierr);
409 ierr = m_field.set_global_ghost_vector(
410 "ELASTIC_MECHANICS",ROW,D,INSERT_VALUES,SCATTER_REVERSE
411 ); CHKERRQ(ierr);
412
413 //post-processing the resutls
414 post_proc.setDoPreProcess();
415 post_proc.unSetDoPostProcess();
416 ierr = m_field.loop_finite_elements(
417 "ELASTIC_MECHANICS","ELASTIC",post_proc
418 ); CHKERRQ(ierr);
419 post_proc.unSetDoPreProcess();
420 post_proc.setDoPostProcess();
421 {
422 ostringstream sss;
423 sss << "mode_" << "Disp" << "_" << ii << ".h5m";
424 rval = post_proc.postProcMesh.write_file(
425 sss.str().c_str(),"MOAB","PARALLEL=WRITE_PART"
426 ); CHKERRQ_MOAB(rval);
427 }
428
429 ierr = VecZeroEntries(stress_homo); CHKERRQ(ierr);
430 ierr = m_field.loop_finite_elements(
431 "ELASTIC_MECHANICS","LAGRANGE_ELEM",lagrangian_element.getLoopFeRVEBCStress()
432 ); CHKERRQ(ierr);
434 PETSC_NULL,"-my_rve_volume",&rve_volume,PETSC_NULL
435 ); CHKERRQ(ierr);
436 ierr = VecAssemblyBegin(stress_homo); CHKERRQ(ierr);
437 ierr = VecAssemblyEnd(stress_homo); CHKERRQ(ierr);
438 ierr = VecScale(stress_homo,1.0/rve_volume); CHKERRQ(ierr);
439 ierr = VecGhostUpdateBegin(stress_homo,INSERT_VALUES,SCATTER_FORWARD); CHKERRQ(ierr);
440 ierr = VecGhostUpdateEnd(stress_homo,INSERT_VALUES,SCATTER_FORWARD); CHKERRQ(ierr);
441 for(int jj=0; jj<6; jj++) {
442 Dmat(jj,ii) = avec[jj];
443 }
444 }
445
446 ierr = VecRestoreArray(stress_homo,&avec); CHKERRQ(ierr);
447 PetscPrintf(
448 PETSC_COMM_WORLD,"\nHomogenised Stiffens Matrix = \n\n"
449 );
450
451 for(int ii=0; ii<6; ii++) {
452 PetscPrintf(
453 PETSC_COMM_WORLD,
454 "stress %d\t\t%8.5e\t\t%8.5e\t\t%8.5e\t\t%8.5e\t\t%8.5e\t\t%8.5e\n",
455 ii,Dmat(ii,0),Dmat(ii,1),Dmat(ii,2),Dmat(ii,3),Dmat(ii,4),Dmat(ii,5)
456 );
457 }
458 //==============================================================================================================================
459
460
461
462 //Open mesh_file_name.txt for writing
463 ofstream myfile;
464 myfile.open ((string(mesh_file_name)+".txt").c_str());
465
466 //Output displacements
467 myfile << "<<<< Homonenised stress >>>>>" << endl;
468
469 if(pcomm->rank()==0){
470 for(int ii=0; ii<6; ii++){
471 myfile << boost::format("%.3lf") % roundn(Dmat(ii,0)) << endl;
472 avec++;
473 }
474 }
475 //Close mesh_file_name.txt
476 myfile.close();
477
478
479
480
481
482 //detroy matrices
483 for(int ii = 0;ii<6;ii++) {
484 ierr = VecDestroy(&F[ii]); CHKERRQ(ierr);
485 }
486 ierr = VecDestroy(&D); CHKERRQ(ierr);
487 ierr = MatDestroy(&Aij); CHKERRQ(ierr);
488 ierr = KSPDestroy(&solver); CHKERRQ(ierr);
489 ierr = VecDestroy(&stress_homo); CHKERRQ(ierr);
490
491 ierr = PetscTime(&v2);CHKERRQ(ierr);
492 ierr = PetscGetCPUTime(&t2);CHKERRQ(ierr);
493
494 PetscSynchronizedPrintf(PETSC_COMM_WORLD,"Total Rank %d Time = %f CPU Time = %f\n",pcomm->rank(),v2-v1,t2-t1);
495
496 }
498
499
501
502}
DEPRECATED typedef PostProcStress PostPorcStress
@ COL
@ ROW
#define CATCH_ERRORS
Catch errors.
@ MF_ZERO
@ AINSWORTH_LEGENDRE_BASE
Ainsworth Cole (Legendre) approx. base .
Definition definitions.h:60
@ H1
continuous field
Definition definitions.h:85
#define MYPCOMM_INDEX
default communicator number PCOMM
@ SIDESET
#define CHKERRQ_MOAB(a)
check error code of MoAB function
constexpr int order
Order displacement.
@ F
virtual MoFEMErrorCode build_finite_elements(int verb=DEFAULT_VERBOSITY)=0
Build finite elements.
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_dofs(const Problem *problem_ptr, const std::string &field_name, RowColData rc, DofMethod &method, int lower_rank, int upper_rank, int verb=DEFAULT_VERBOSITY)=0
Make a loop over dofs.
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.
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
double roundn(double n)
static char help[]
double D
char mesh_file_name[255]
const FTensor::Tensor2< T, Dim, Dim > Vec
static MoFEMErrorCodeGeneric< PetscErrorCode > ierr
static MoFEMErrorCodeGeneric< moab::ErrorCode > rval
std::bitset< BITREFLEVEL_SIZE > BitRefLevel
Bit structure attached to each entity identifying to what mesh entity is attached.
Definition Types.hpp:40
PetscErrorCode PetscOptionsGetInt(PetscOptions *, const char pre[], const char name[], PetscInt *ivalue, PetscBool *set)
PetscErrorCode PetscOptionsGetReal(PetscOptions *, const char pre[], const char name[], PetscReal *dval, PetscBool *set)
PetscErrorCode PetscOptionsGetString(PetscOptions *, const char pre[], const char name[], char str[], size_t size, PetscBool *set)
Hook equation.
Definition Hooke.hpp:21
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.
virtual int get_comm_rank() const =0
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:118
Deprecated interface functions.
DEPRECATED MoFEMErrorCode seed_ref_level_3D(const EntityHandle meshset, const BitRefLevel &bit, int verb=-1)
seed 2D entities in the meshset and their adjacencies (only TETs adjacencies) in a particular BitRefL...
Projection of edge entities with one mid-node on hierarchical basis.
MoFEMErrorCode postProcess()
MoFEMErrorCode preProcess()
structure grouping operators and data used for calculation of nonlinear elastic element
Calculate volume.

◆ roundn()

double roundn ( double  n)

Definition at line 52 of file homogenisation_disp_atom_test.cpp.

53{
54 //break n into fractional part (fract) and integral part (intp)
55 double fract, intp;
56 fract = modf(n,&intp);
57
58 // //round up
59 // if (fract>=.5)
60 // {
61 // n*=10;
62 // ceil(n);
63 // n/=10;
64 // }
65 // //round down
66 // if (fract<=.5)
67 // {
68 // n*=10;
69 // floor(n);
70 // n/=10;
71 // }
72 // case where n approximates zero, set n to "positive" zero
73 if (abs(intp)==0)
74 {
75 if(abs(fract)<=RND_EPS)
76 {
77 n=0.000;
78 }
79 }
80 return n;
81}
const double n
refractive index of diffusive medium

Variable Documentation

◆ help

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

Definition at line 47 of file homogenisation_disp_atom_test.cpp.