18 using namespace MoFEM;
22 #include <metaImage.h>
25 #include <moab/Skinner.hpp>
26 #include <moab/AdaptiveKDTree.hpp>
39 #error "You need compile users modules with MetaIO -DWITH_METAIO=1"
42 int main(
int argc,
char *argv[]) {
51 PetscBool flg_file = PETSC_FALSE;
52 char meta_file_name[255];
53 PetscBool meta_flg_file = PETSC_FALSE;
55 PetscBool is_atom_test = PETSC_FALSE;
58 ierr = PetscOptionsBegin(PETSC_COMM_WORLD,
"",
"Bone remodeling",
"none"); CHKERRQ(
ierr);
59 ierr = PetscOptionsString(
65 ierr = PetscOptionsString(
68 "file.mhd",meta_file_name,255,&meta_flg_file
77 ierr = PetscOptionsBool(
79 "is used with testing, exit with error when diverged",
"",
80 PETSC_FALSE,&is_atom_test,PETSC_NULL
83 ierr = PetscOptionsInt(
85 "default approximation order",
"",
89 ierr = PetscOptionsEnd(); CHKERRQ(
ierr);
93 MetaImage meta_file(meta_file_name);
94 cout <<
"Quantity " << meta_file.Quantity() << endl;
95 const int *dim_size = meta_file.DimSize();
96 cout <<
"Image dimension: " << dim_size[0] <<
" " << dim_size[1] <<
" " << dim_size[2] << endl;
97 const double *elemet_size = meta_file.ElementSize();
98 cout <<
"Image element size: " << elemet_size[0] <<
" " << elemet_size[1] <<
" " << elemet_size[2] << endl;
99 const double *offset = meta_file.Offset();
100 cout <<
"Image offset: " << offset[0] <<
" " << offset[1] <<
" " << offset[2] << endl;
101 const double * transform_matrix = meta_file.TransformMatrix();
102 cout <<
"Image Transform Matrix:\n";
103 for(
int rr = 0;rr<3;rr++) {
104 for(
int cc = 0;cc<3;cc++) {
105 cout << transform_matrix[rr*3+cc] <<
" ";
111 if(flg_file != PETSC_TRUE) {
112 SETERRQ(PETSC_COMM_SELF,1,
"*** ERROR -my_file (MESH FILE NEEDED)");
117 ParallelComm* pcomm = ParallelComm::get_pcomm(&moab,
MYPCOMM_INDEX);
118 if(pcomm == NULL) pcomm =
new ParallelComm(&moab,PETSC_COMM_WORLD);
135 ierr = meshsets_manager_ptr->setMeshsetFromFile(); CHKERRQ(
ierr);
137 PetscPrintf(PETSC_COMM_WORLD,
"Read meshset. Added meshsets for bc.cfg\n");
141 "%s",
static_cast<std::ostringstream&
>(std::ostringstream().seekp(0) << *it << endl).str().c_str()
150 string name = it->getName();
151 if (name.compare(0,14,
"NO_REMODELLING") == 0) {
156 meshset,MBTET,tets_block,
true
158 tets_all = subtract(tets_all,tets_block);
205 rval = moab.get_adjacencies(
206 faces,1,
false,edges,moab::Interface::UNION
216 ierr = m_field.
loop_dofs(
"MESH_NODE_POSITIONS",ent_method_material); CHKERRQ(
ierr);
245 DMType dm_name =
"DM_RHO";
248 ierr = DMCreate(PETSC_COMM_WORLD,&dm_rho);CHKERRQ(
ierr);
249 ierr = DMSetType(dm_rho,dm_name);CHKERRQ(
ierr);
253 ierr = DMSetFromOptions(dm_rho); CHKERRQ(
ierr);
260 ierr = DMSetUp(dm_rho); CHKERRQ(
ierr);
272 int volume_vec_ghost[] = { 0 };
273 ierr = VecCreateGhost(
274 PETSC_COMM_WORLD,(!m_field.
get_comm_rank())?1:0,1,1,volume_vec_ghost,&volume_vec
276 ierr = VecZeroEntries(volume_vec); CHKERRQ(
ierr);
278 ierr = VecDuplicate(volume_vec,&mass_vec); CHKERRQ(
ierr);
280 ierr = VecDuplicate(volume_vec,&mass_vec_approx); CHKERRQ(
ierr);
287 list_of_operators.push_back(
new OpMassCalculation(
"RHO",mass_vec,data_from_meta_io));
290 ierr = VecAssemblyBegin(volume_vec); CHKERRQ(
ierr);
291 ierr = VecAssemblyEnd(volume_vec); CHKERRQ(
ierr);
293 ierr = VecSum(volume_vec,&volume); CHKERRQ(
ierr);
294 ierr = PetscPrintf(PETSC_COMM_WORLD,
"Volume %0.32g\n",volume); CHKERRQ(
ierr);
296 ierr = VecAssemblyBegin(mass_vec); CHKERRQ(
ierr);
297 ierr = VecAssemblyEnd(mass_vec); CHKERRQ(
ierr);
299 ierr = VecSum(mass_vec,&mass); CHKERRQ(
ierr);
300 ierr = PetscPrintf(PETSC_COMM_WORLD,
"Mass %0.32g\n",mass); CHKERRQ(
ierr);
302 ierr = VecDestroy(&volume_vec); CHKERRQ(
ierr);
303 ierr = VecDestroy(&mass_vec); CHKERRQ(
ierr);
308 ierr = DMCreateMatrix(dm_rho,&
A); CHKERRQ(
ierr);
321 boost::shared_ptr<VectorDouble> dist_value = common_data.
distanceValue;
338 ierr = MatAssemblyBegin(
A,MAT_FINAL_ASSEMBLY); CHKERRQ(
ierr);
339 ierr = MatAssemblyEnd(
A,MAT_FINAL_ASSEMBLY); CHKERRQ(
ierr);
340 ierr = VecGhostUpdateBegin(
F,ADD_VALUES,SCATTER_REVERSE);
341 ierr = VecGhostUpdateEnd(
F,ADD_VALUES,SCATTER_REVERSE);
342 ierr = VecAssemblyBegin(
F); CHKERRQ(
ierr);
351 ierr = KSPCreate(PETSC_COMM_WORLD,&ksp); CHKERRQ(
ierr);
352 ierr = KSPSetOperators(ksp,
A,
A); CHKERRQ(
ierr);
353 ierr = KSPSetFromOptions(ksp); CHKERRQ(
ierr);
357 ierr = VecGhostUpdateBegin(
D,INSERT_VALUES,SCATTER_FORWARD); CHKERRQ(
ierr);
358 ierr = VecGhostUpdateEnd(
D,INSERT_VALUES,SCATTER_FORWARD); CHKERRQ(
ierr);
368 ierr = VecAssemblyBegin(mass_vec_approx); CHKERRQ(
ierr);
369 ierr = VecAssemblyEnd(mass_vec_approx); CHKERRQ(
ierr);
371 ierr = VecSum(mass_vec_approx,&mass_approx); CHKERRQ(
ierr);
372 ierr = PetscPrintf(PETSC_COMM_WORLD,
"Mass after approximation %0.32g\n",mass_approx); CHKERRQ(
ierr);
374 if( abs(mass_approx - volume) > 1.0e-2) {
378 ierr = VecDestroy(&mass_vec_approx); CHKERRQ(
ierr);
393 ierr = DMDestroy(&dm_rho);
398 CHKERR moab.write_file(
"analysis_mesh.h5m");