Exemple #1
0
int main(int argc, char *argv[])
{
  MPI_Comm       comm;
  Options        options;
  PetscErrorCode ierr;

  PetscFunctionBegin;
  ierr = PetscInitialize(&argc, &argv, (char *) 0, NULL);CHKERRQ(ierr);
  comm = PETSC_COMM_WORLD;

  try {
    ierr = ProcessOptions(comm, &options);CHKERRQ(ierr);
    Obj<ALE::Mesh> mesh;
    Mesh mesh_set[options.levels];
    for (int i = 0; i < options.levels; i++) {
      ierr = MeshCreate(comm, &mesh_set[i]);CHKERRQ(ierr);
    };
    ierr = CreateMesh(comm, mesh, &options);CHKERRQ(ierr);
    
    MeshSetMesh(mesh_set[0], mesh);
    ierr = MeshIDBoundary(mesh_set[0]);
    mesh->markBoundaryCells("marker");
    ierr = PetscPrintf(mesh->comm(), "%d boundary vertices, %d boundary cells\n", mesh->getLabelStratum("marker", 1)->size(), mesh->getLabelStratum("marker", 2)->size());
    ierr = MeshSpacingFunction(mesh_set[0]);
    //ierr = MeshIDBoundary(mesh_set[0]);
//    mesh->createLabel("marker");
//    mesh->markBoundaryCells("marker", 1, 2, false);
    MeshCreateHierarchyLabel_Link(mesh_set[0], options.coarseFactor, options.levels, &mesh_set[1],NULL,options.curvatureCutoff );
    Obj<ALE::Mesh> ale_meshes[options.levels];
    for (int i = 0; i < options.levels; i++) {
      MeshGetMesh(mesh_set[i], ale_meshes[i]);
    }
    Hierarchy_qualityInfo(ale_meshes, options.levels);
    //ierr = MeshCoarsenMesh(m, pow(options.coarseFactor, 2), &n);
    //ierr = MeshGetMesh(n, mesh);
    //ierr = MeshLocateInMesh(m, n);
   // Obj<ALE::Mesh::sieve_type> sieve = new ALE::Mesh::sieve_type(mesh->comm(), 0);
   // mesh->getTopology()->setPatch(options.levels, sieve);
   // mesh->getTopology()->stratify();
    char vtkfilename[128];
    for (int i = 0; i < options.levels; i++) {
      sprintf(vtkfilename, "testMesh%d.vtk", i);
      ierr = OutputVTK(ale_meshes[i], &options, vtkfilename);CHKERRQ(ierr);
    }
  } catch (ALE::Exception e) {
    std::cout << e << std::endl;
  }
  ierr = PetscFinalize();CHKERRQ(ierr);
  PetscFunctionReturn(0);
}
Exemple #2
0
int main(int argc, char *argv[])
{
  MPI_Comm       comm;
  Options        options;
  PetscErrorCode ierr;

  PetscFunctionBegin;
  ierr = PetscInitialize(&argc, &argv, (char *) 0, NULL);CHKERRQ(ierr);
  comm = PETSC_COMM_WORLD;

  try {
    ierr = ProcessOptions(comm, &options);CHKERRQ(ierr);
    Obj<ALE::Mesh> m;
    Mesh mesh;
    ierr = MeshCreate(comm, &mesh);
    m = new ALE::Mesh(comm, options.debug);
    ierr = CreateMesh(comm, m, &options);CHKERRQ(ierr);
    ierr = MeshSetMesh(mesh, m);
    //ierr = MeshIDBoundary(mesh);
    //create the spacing function on the original mesh
    
    m->markBoundaryCells("marker");
    //    PetscPrintf(m->comm(), "marked the boundary cells\n");

    int nMeshes;
    Obj<ALE::Mesh> * coarsened_mesh = Hierarchy_createHierarchy_adaptive(m, 60, 10, options.coarseFactor, &nMeshes);
    Hierarchy_qualityInfo(coarsened_mesh, nMeshes);
    char vtkfilename[256];
    sprintf(vtkfilename, "fine_mesh.vtk");
    ierr = OutputVTK(m, &options, vtkfilename);CHKERRQ(ierr);
    for (int i = 1; i < nMeshes; i++) {
      sprintf(vtkfilename, "coarse_mesh%d.vtk", i);
      ierr = OutputVTK(coarsened_mesh[i], &options, vtkfilename);CHKERRQ(ierr);
    } 
  } catch (ALE::Exception e) {
    std::cout << e << std::endl;
  }
  ierr = PetscFinalize();
  PetscFunctionReturn(0);
}