Getting No. of Fibres and their index to be used for Potential Flow Problem
48 {
49
51
52 try {
53
54 moab::Core mb_instance;
55 moab::Interface& moab = mb_instance;
56 int rank;
57 MPI_Comm_rank(PETSC_COMM_WORLD,&rank);
58
59 PetscBool flg = PETSC_TRUE;
62 if(flg != PETSC_TRUE) {
63 SETERRQ(PETSC_COMM_SELF,1,"*** ERROR -my_file (MESH FILE NEEDED)");
64 }
67 if(flg != PETSC_TRUE) {
69 }
70
71
72
73 PetscInt mesh_refinement_level;
75 if(flg != PETSC_TRUE) {
76 mesh_refinement_level = 0;
77 }
78
79
80 const char *option;
81 option = "";
83 ParallelComm* pcomm = ParallelComm::get_pcomm(&moab,
MYPCOMM_INDEX);
84 if(pcomm == NULL) pcomm = new ParallelComm(&moab,PETSC_COMM_WORLD);
85
86
91
92
93
94
95
96 Range SurTrisNeg, SurTrisPos;
97 ierr = m_field.get_cubit_msId_entities_by_dimension(101,
SIDESET,2,SurTrisNeg,
true); CHKERRQ(
ierr);
98 ierr = PetscPrintf(PETSC_COMM_WORLD,
"number of SideSet 101 = %d\n",SurTrisNeg.size()); CHKERRQ(
ierr);
99 ierr = m_field.get_cubit_msId_entities_by_dimension(102,
SIDESET,2,SurTrisPos,
true); CHKERRQ(
ierr);
100 ierr = PetscPrintf(PETSC_COMM_WORLD,
"number of SideSet 102 = %d\n",SurTrisPos.size()); CHKERRQ(
ierr);
101
102 Range SurNodesNeg,SurNodesPos;
104 cout<<" All nodes on negative surfaces " << SurNodesNeg.size()<<endl;
106 cout<<" All nodes on positive surfaces " << SurNodesPos.size()<<endl;
107
108
109 double roundfact=1e3; double coords_nodes[3];
110 for(Range::iterator nit = SurNodesNeg.begin(); nit!=SurNodesNeg.end(); nit++) {
112
113 coords_nodes[0]=round(coords_nodes[0]*roundfact)/roundfact;
114 coords_nodes[1]=round(coords_nodes[1]*roundfact)/roundfact;
115 coords_nodes[2]=round(coords_nodes[2]*roundfact)/roundfact;
117
118 }
119
120 for(Range::iterator nit = SurNodesPos.begin(); nit!=SurNodesPos.end(); nit++) {
122
123
124 coords_nodes[0]=round(coords_nodes[0]*roundfact)/roundfact;
125 coords_nodes[1]=round(coords_nodes[1]*roundfact)/roundfact;
126 coords_nodes[2]=round(coords_nodes[2]*roundfact)/roundfact;
128
129 }
130
131
132
133
134
135
138
139
140 int noOfFibres=0;
142
143 std::size_t found=it->getName().find("PotentialFlow");
144 if (found==std::string::npos) continue;
145 noOfFibres += 1;
146 }
147 cout<<"No. of Fibres for Potential Flow : "<<noOfFibres<<endl;
148
149 vector<int> fibreList(noOfFibres,0);
150 int aaa=0;
151
153
154 std::size_t interfaceFound=it->getName().find("PotentialFlow_");
155 if (interfaceFound==std::string::npos) continue;
156
157 std::string str2 = it->getName().substr (14,50);
158
159 fibreList[aaa] = atoi(str2.c_str());
160
161 aaa += 1;
162 }
163
164
170
171
173
175
177 int def_meshset_info[2] = {0,0};
178 rval = moab.tag_get_handle(
"MESHSET_INFO",2,MB_TYPE_INTEGER,th_meshset_info,MB_TAG_CREAT|MB_TAG_SPARSE,&def_meshset_info);
179
180 int meshset_data[2];
183
185 vector<BitRefLevel> bit_levels;
187
188
189 int ll = 1;
190
191
192
194
195 std::size_t interfaceFound=cit->getName().find("interface");
196 if (interfaceFound==std::string::npos) continue;
197
198 ierr = PetscPrintf(PETSC_COMM_WORLD,
"Insert Interface %d\n",cit->getMeshsetId()); CHKERRQ(
ierr);
200 int meshset_data_int[2];
201 rval = moab.tag_get_data(th_meshset_info,&cubit_meshset,1,meshset_data_int);
CHKERRQ_MOAB(
rval);
202 if(meshset_data_int[1]==0){
203
206 ierr = m_field.get_entities_by_type_and_ref_level(bit_levels.back(),
BitRefLevel().set(),MBTET,ref_level_meshset); CHKERRQ(
ierr);
207 ierr = m_field.get_entities_by_type_and_ref_level(bit_levels.back(),
BitRefLevel().set(),MBPRISM,ref_level_meshset); CHKERRQ(
ierr);
208 Range ref_level_tets;
210
211 ierr = interface_ptr->
getSides(cubit_meshset,bit_levels.back(),
true); CHKERRQ(
ierr);
212
214
215 ierr = interface_ptr->
splitSides(ref_level_meshset,bit_levels.back(),cubit_meshset,
true,
true,0); CHKERRQ(
ierr);
216
218 int meshset_data_ins[2] = {ll,1};
219 rval = moab.tag_set_data(th_meshset_info,&cubit_meshset,1,meshset_data_ins);
CHKERRQ_MOAB(
rval);
220 }
221
224 ierr = m_field.update_meshset_by_entities_children(cubit_meshset,bit_levels.back(),cubit_meshset,MBVERTEX,
true); CHKERRQ(
ierr);
225 ierr = m_field.update_meshset_by_entities_children(cubit_meshset,bit_levels.back(),cubit_meshset,MBEDGE,
true); CHKERRQ(
ierr);
226 ierr = m_field.update_meshset_by_entities_children(cubit_meshset,bit_levels.back(),cubit_meshset,MBTRI,
true); CHKERRQ(
ierr);
227 ierr = m_field.update_meshset_by_entities_children(cubit_meshset,bit_levels.back(),cubit_meshset,MBTET,
true); CHKERRQ(
ierr);
228 }
229 }
230
231
232
233 int meshset_data_root[2]={ll,0};
235
236
239 ierr = m_field.get_entities_by_type_and_ref_level(bit_levels.back(),
BitRefLevel().set(),MBTET,out_tet_meshset); CHKERRQ(
ierr);
241
242
243
246 ierr = m_field.get_entities_by_type_and_ref_level(bit_levels.back(),
BitRefLevel().set(),MBPRISM,out_meshset_prism); CHKERRQ(
ierr);
248
249
252 ierr = m_field.get_entities_by_ref_level(bit_levels.back(),
BitRefLevel().set(),out_meshset); CHKERRQ(
ierr);
254
255 Range LatestRefinedTets;
256 rval = moab.get_entities_by_type(out_meshset, MBTET,LatestRefinedTets,
true);
CHKERRQ_MOAB(
rval);
257
258 Range LatestRefinedTris;
259 rval = moab.get_entities_by_type(out_meshset, MBTRI,LatestRefinedTris,
true);
CHKERRQ_MOAB(
rval);
260
261
263
264
267
268
273
278
279
286
287
288
292
294 if(pcomm->rank()==0) {
296 }
297
298
299
300
301 int pressure_sideset_id = 10000;
302 for (int cc = 0; cc < noOfFibres; cc++) {
303 pressure_sideset_id=pressure_sideset_id+100;
304 ostringstream rrr, ppp1, ppp2;
305 rrr << "PotentialFlow_" << fibreList[cc];
308 if(it->getName() == rrr.str().c_str() ) {
309
312 new_tets = intersect(LatestRefinedTets,TetsInBlock);
313
315 }
316 }
317
318 Range new_tris_1, new_tris_2;
319
320 ppp1 << "PressureIO_" << fibreList[cc] <<"_1";
321 ppp2 << "PressureIO_" << fibreList[cc] <<"_2";
323 if (ppp1.str().c_str()==it->getName() || it->getMeshsetId() == pressure_sideset_id+1){
326 new_tris_1 = intersect(LatestRefinedTris,tris);
328 }
329
330
331 if (ppp2.str().c_str()==it->getName() || it->getMeshsetId() == pressure_sideset_id+2){
334 new_tris_2 = intersect(LatestRefinedTris,tris);
336 }
337 }
338
339
341
342
344
346
348
349 ierr = m_field.build_problems(); CHKERRQ(
ierr);
350
351 ierr = m_field.partition_problem(
"POTENTIAL_PROBLEM" ); CHKERRQ(
ierr);
352 ierr = m_field.partition_finite_elements(
"POTENTIAL_PROBLEM" ); CHKERRQ(
ierr);
353 ierr = m_field.partition_ghost_dofs(
"POTENTIAL_PROBLEM" ); CHKERRQ(
ierr);
354
355 ierr = m_field.VecCreateGhost(
"POTENTIAL_PROBLEM" ,
ROW,&
F); CHKERRQ(
ierr);
356 ierr = m_field.VecCreateGhost(
"POTENTIAL_PROBLEM" ,
COL,&
D); CHKERRQ(
ierr);
357 ierr = m_field.MatCreateMPIAIJWithArrays(
"POTENTIAL_PROBLEM" ,&A); CHKERRQ(
ierr);
358
360 ierr = m_field.
loop_dofs(
"MESH_NODE_POSITIONS",ent_method_material); CHKERRQ(
ierr);
361
362 ostringstream zero_pressure;
363 zero_pressure << "ZeroPressure_" << fibreList[cc];
364
367 if (zero_pressure.str().c_str()==it->getName()){
375 fix_nodes.insert(adj.begin(),adj.end());
377 fix_nodes.insert(adj.begin(),adj.end());
379 }
380 }
382
384
386 ierr = VecGhostUpdateBegin(
F,INSERT_VALUES,SCATTER_FORWARD); CHKERRQ(
ierr);
387 ierr = VecGhostUpdateEnd(
F,INSERT_VALUES,SCATTER_FORWARD); CHKERRQ(
ierr);
388 ierr = MatZeroEntries(A); CHKERRQ(
ierr);
389
390
391
392 boost::ptr_map<string,NeummanForcesSurface> neumann_forces;
393 string fe_name_str = "FLUX_FE";
396 if (ppp1.str().c_str()==it->getName()
397 || ppp2.str().c_str()==it->getName()
398 || it->getMeshsetId()==pressure_sideset_id+1
399 || it->getMeshsetId()==pressure_sideset_id+2){
400 bool ho_geometry = m_field.
check_field(
"MESH_NODE_POSITIONS");
401 ierr = neumann_forces.at(
"FLUX_FE").addFlux(
"POTENTIAL_FIELD",
F,it->getMeshsetId(),ho_geometry); CHKERRQ(
ierr);
402 }
403 }
404 boost::ptr_map<string,NeummanForcesSurface>::iterator mit = neumann_forces.begin();
405 for(;mit!=neumann_forces.end();mit++) {
407 }
408
409 LaplacianElem elem(m_field,A,
F);
411
412
414
415 ierr = MatAssemblyBegin(A,MAT_FINAL_ASSEMBLY); CHKERRQ(
ierr);
416 ierr = MatAssemblyEnd(A,MAT_FINAL_ASSEMBLY); CHKERRQ(
ierr);
417
418 ierr = VecAssemblyBegin(
F); CHKERRQ(
ierr);
420
421
422 ierr = MatSetOption(A,MAT_SPD,PETSC_TRUE); CHKERRQ(
ierr);
423
424 KSP solver;
425 ierr = KSPCreate(PETSC_COMM_WORLD,&solver); CHKERRQ(
ierr);
426 ierr = KSPSetOperators(solver,A,A); CHKERRQ(
ierr);
427 ierr = KSPSetFromOptions(solver); CHKERRQ(
ierr);
428 ierr = KSPSetUp(solver); CHKERRQ(
ierr);
429
431 ierr = VecGhostUpdateBegin(
D,INSERT_VALUES,SCATTER_FORWARD); CHKERRQ(
ierr);
432 ierr = VecGhostUpdateEnd(
D,INSERT_VALUES,SCATTER_FORWARD); CHKERRQ(
ierr);
433 ierr = m_field.set_global_ghost_vector(
"POTENTIAL_PROBLEM",
ROW,
D,INSERT_VALUES,SCATTER_REVERSE); CHKERRQ(
ierr);
434
435 if(pcomm->rank()==0) {
437 }
438
439
443
445
448 ierr = MatDestroy(&A); CHKERRQ(
ierr);
449 ierr = KSPDestroy(&solver); CHKERRQ(
ierr);
450 }
451
452
454 double def_val = 0;
455 rval = moab.tag_get_handle(
"PHI",1,MB_TYPE_DOUBLE,th_phi,MB_TAG_CREAT|MB_TAG_SPARSE,&def_val);
CHKERRQ_MOAB(
rval);
458 double val = dof->get()->getFieldData();
460 }
461
463 ierr = m_field.
loop_dofs(
"POTENTIAL_FIELD",ent_method_phi_on_10nodeTet); CHKERRQ(
ierr);
464 ent_method_phi_on_10nodeTet.setNodes = false;
465 ierr = m_field.
loop_dofs(
"POTENTIAL_FIELD",ent_method_phi_on_10nodeTet); CHKERRQ(
ierr);
466
467 if(pcomm->rank()==0) {
469 }
470
471 if(pcomm->rank()==0) {
472 rval = moab.write_file(
"out_potential_flow.vtk",
"VTK",
"",&out_meshset_fibres,1);
CHKERRQ_MOAB(
rval);
473 }
474
475 }
477
479}
DEPRECATED typedef DirichletFixFieldAtEntitiesBc FixBcAtEntities
DEPRECATED typedef NeumannForcesSurface NeummanForcesSurface
#define CATCH_ERRORS
Catch errors.
@ AINSWORTH_LEGENDRE_BASE
Ainsworth Cole (Legendre) approx. base nme:nme847.
#define MYPCOMM_INDEX
default communicator number PCOMM
#define CHKERRQ_MOAB(a)
check error code of MoAB function
#define _IT_GET_DOFS_FIELD_BY_NAME_FOR_LOOP_(MFIELD, NAME, IT)
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_row(const std::string &fe_name, const std::string name_row)=0
set field row which finite element use
virtual MoFEMErrorCode modify_finite_element_add_field_data(const std::string &fe_name, const std::string name_field)=0
set finite element field data
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 bool check_field(const std::string &name) const =0
check if field is in database
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 problem_basic_method_postProcess(const Problem *problem_ptr, BasicMethod &method, int verb=DEFAULT_VERBOSITY)=0
Set data for BasicMethod.
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.
#define _IT_CUBITMESHSETS_BY_BCDATA_TYPE_FOR_LOOP_(MESHSET_MANAGER, CUBITBCTYPE, IT)
Iterator that loops over a specific Cubit MeshSet in a moFEM field.
#define _IT_CUBITMESHSETS_FOR_LOOP_(MESHSET_MANAGER, IT)
Iterator that loops over all the Cubit MeshSets in a moFEM field.
#define _IT_CUBITMESHSETS_BY_SET_TYPE_FOR_LOOP_(MESHSET_MANAGER, CUBITBCTYPE, IT)
Iterator that loops over a specific Cubit MeshSet having a particular BC meshset in a moFEM field.
virtual MoFEMErrorCode get_problem_finite_elements_entities(const std::string name, const std::string &fe_name, const EntityHandle meshset)=0
add finite elements to the meshset
virtual MoFEMErrorCode add_problem(const std::string &name, enum MoFEMTypes bh=MF_EXCL, int verb=DEFAULT_VERBOSITY)=0
Add problem.
virtual MoFEMErrorCode clear_problems(int verb=DEFAULT_VERBOSITY)=0
clear problems
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
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.
PetscErrorCode PetscOptionsGetInt(PetscOptions *, const char pre[], const char name[], PetscInt *ivalue, PetscBool *set)
PetscErrorCode PetscOptionsGetString(PetscOptions *, const char pre[], const char name[], char str[], size_t size, PetscBool *set)
virtual moab::Interface & get_moab()=0
virtual MoFEMErrorCode problem_basic_method_preProcess(const Problem *problem_ptr, BasicMethod &method, int verb=DEFAULT_VERBOSITY)=0
Set data for BasicMethod.
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 MoFEMErrorCode remove_ents_from_finite_element(const std::string name, const EntityHandle meshset, const EntityType type, int verb=DEFAULT_VERBOSITY)=0
remove entities from given refinement level to finite element database
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.
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...
Create interface from given surface and insert flat prisms in-between.
MoFEMErrorCode getSides(const int msId, const CubitBCType cubit_bc_type, const BitRefLevel mesh_bit_level, const bool recursive, int verb=QUIET)
Store tetrahedra from each side of the interface separately in two child meshsets of the parent meshs...
MoFEMErrorCode splitSides(const EntityHandle meshset, const BitRefLevel &bit, const int msId, const CubitBCType cubit_bc_type, const bool add_interface_entities, const bool recursive=false, int verb=QUIET)
Split nodes and other entities of tetrahedra on both sides of the interface and insert flat prisms in...
Projection of edge entities with one mid-node on hierarchical basis.
virtual MoFEMErrorCode query_interface(boost::typeindex::type_index type_index, UnknownInterface **iface) const =0