Zahur,
Hi, Zahur,
First of all, you need to look how bit levels work, but you know that already, just for reference here is a
link (Section Explaining BitRefLevel).
So procure can work; like that:
1) you start with the case that all entities have bit-level set to 1000..0. That includes tetrahedra and prisms from the previous load step, let say n.
Tets: 00..01
Prisms: 00..01
2) next you set second bit to all tetrahedra:
{
Range tets_at_bit;
BitRefLevel from_bit;
from_bit.set(0); // 00..01
ierr = m_mield.get_entities_by_type_and_ref_level(from_bit,BitRefLevel().set(),MBTET,tets_at_bit); CHKERRQ(ierr);
from_bit.set(1); // 00..11
ierr = m_field.seed_ref_level(tets_at_bit,from_bit,true); CHKERRQ(ierr);
}
3) next you set last bit on all prisms, we will use last two bits as garbage,
Prisms: 00..01 set to 10..00
{
Range prims_at_bit;
BitRefLevel set_bit;
set_bit.set(BITREFLEVEL_SIZE-1); // 10..00
const RefEntity_multiIndex *ref_ent_ptr;
ierr = m_field.get_ref_ents(&ref_ent_ptr);
RefEntity_multiIndex::index<EntType_mi_tag>::type::iterator dit,hi_dit;
dit = ref_ent_ptr->lower_bound(MBPRISM);
hi_dit = ref_ent_ptr->upper_bound(MBPRISM);
for(;dit!=hi_dit;dit++) {
ref_ent_ptr->project<0>(dit),RefEntity_change_set_bit(set_bit)
}
} 4) next you create new prisms, with your algorithm
5) Set second bit to new prisms
BitRefLevel set_bit;
set_bit.set(1); // 00..10
ierr = m_field. seed_ref_level(range_slave_master_prisms,set_bit,false); CHKERRQ(ierr);
5) Now you shift bit of all entities to the right as (this is to make sure we not run out of bit level as in MOFEM currently we have 32 bit level):
Tets: 00..11 -> 00..01
New Prisms: 00..10 -> 00..01
Old Prims: 10..00 -> 01..00
ierr = mField.shift_right_bit_ref(1); CHKERRQ(ierr);
6) You can now delete all entities which have bit 01..00 (Old Prism). That should include fields & finite elements and entities in moab database. Do not do it now, first check if algorithm without deletion works. Note last two bits works as a garbage bin, you just accumulate on those bits everything with you do not need from previous load steps.
7) Now you have to create new DM and matrices with new adjacencies. Of course, if you build composite DM before, you only rebuild sub DM with contact part. Also, you can use block solver; field split solver. This is another step, you can do that later.
Now simply rebuild the whole problem and create vectors and matrices,
ierr = DMDestroy(&dm);
ierr = DMCreate(PETSC_COMM_WORLD,&dm);CHKERRQ(ierr);
ierr = DMSetType(dm,dm_name);CHKERRQ(ierr);
//set dm datastruture which created mofem datastructures
BitRefLevel problem_bit_level;
problem_bit_level.set(0); // 00..01
ierr = DMMoFEMCreateMoFEM(dm,&m_field,dm_name,problem_bit_level); CHKERRQ(ierr);
ierr = DMSetFromOptions(dm); CHKERRQ(ierr);
ierr = DMMoFEMSetIsPartitioned(dm,is_partitioned); CHKERRQ(ierr);
//add elements to dm
ierr = DMMoFEMAddElement(dm,"ELASTIC"); CHKERRQ(ierr);
ierr = DMMoFEMAddElement(dm,"FORCE_FE"); CHKERRQ(ierr);
ierr = DMMoFEMAddElement(dm,"CONTACT_ELEM"); CHKERRQ(ierr);
ierr = DMSetUp(dm); CHKERRQ(ierr);
We have to clean interface with for setting bit levels, at the moment is a little bit messy and unintuitive. If I find time, I will do it.
Regards,
Lukasz