On Wed, Mar 16, 2016 at 7:23 AM, gouarin <[email protected]>
wrote:

> Hi,
>
> I try to use PETSc to solve BEM problem so I need to construct a surface
> with 3D coordinates. First of all, I would like to plot the mesh and I
> think that the output of the viewer is completely wrong.
>
> Here is a Python example
>
> import sys, petsc4py
> petsc4py.init(sys.argv)
> import numpy as np
> import petsc4py.PETSc as petsc
>
>
> coords = np.array([[0, 0, 0],
>                    [1, 0, 0],
>                    [0, 1, 0],
>                    [1, 1, 0],
>                    [0, 0, 1],
>                    [1, 0, 1],
>                    [0, 1, 1],
>                    [1, 1, 1],
>                   ], dtype=np.double)
>
> cells = np.array([[0, 1, 3, 2],
>                   [1, 5, 7, 3],
>                   [0, 4, 6, 2],
>                   [2, 3, 6, 7],
>

This quad is mis-specified, since 3-6 is a diagonal.


>                   [0, 1, 5, 4],
>                   [4, 5, 7, 6],
>                  ], dtype=np.int32)
>
> dm = petsc.DMPlex().createFromCellList(2, cells, coords,
> interpolate=False, comm=petsc.COMM_WORLD)
>
> viewer = petsc.Viewer().createHDF5('cube.h5', 'w')
> dm.view(viewer)
>
> If you look at the cells in the cube.h5, the numbering of the points is
> wrong.
>

I rewrote this in C, and I can visualize the surface. I then run it using

  ./ex18 -dm_view hdf5:dm.h5

and process that file

  ./bin/petsc_gen_xdmf.py dm.h5

This won't quite work when you have interpolate = PETSC_FALSE, because then
I do not force the 'viz' output,
however it can be forced with a viewer format.

  Thanks,

    Matt


> Thanks,
> Loic
> --
> Loic Gouarin
> Laboratoire de Mathématiques
> Université Paris-Sud
> Bâtiment 425
> 91405 Orsay Cedex
> France
> Tel: (+33) 1 69 15 60 14
> Fax: (+33) 1 69 15 67 18
>



-- 
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which their
experiments lead.
-- Norbert Wiener
static char help[] = "Test surface meshes";

#include <petscdmplex.h>

#undef __FUNCT__
#define __FUNCT__ "main"
int main(int argc, char **argv) {
  DM             dm, dist;
  Mat            mat;
  PetscInt       dim         = 2;
  PetscBool      interpolate = PETSC_TRUE;
  PetscInt       cells[24]  = {0, 2, 3, 1,  1, 3, 7, 5,  0, 4, 6, 2,  2, 6, 7, 3,  0, 1, 5, 4,  4, 5, 7, 6};
  PetscReal      coords[24] = {0, 0, 0,  1, 0, 0,  0, 1, 0,  1, 1, 0,  0, 0, 1,  1, 0, 1,  0, 1, 1,  1, 1, 1};
  PetscErrorCode ierr;

  ierr = PetscInitialize(&argc, &argv, NULL, help); CHKERRQ(ierr);
  ierr = DMPlexCreateFromCellList(PETSC_COMM_WORLD, dim, 6, 8, 4, interpolate, cells, 3, coords, &dm); CHKERRQ(ierr);
  ierr = DMPlexDistribute(dm, 0, NULL, &dist); CHKERRQ(ierr);
  if (dist) {
    ierr = DMDestroy(&dm);CHKERRQ(ierr);
    dm   = dist;
  }
  ierr = DMViewFromOptions(dm, NULL, "-dm_view");CHKERRQ(ierr);
  ierr = DMDestroy(&dm);CHKERRQ(ierr);
  PetscFinalize();
  return 0;
}

Reply via email to