Re: [petsc-users] Error and success codes
Hello, thank you very much for your answer! No, use 0. It's less typing and that is something that will definitely never change. I understand but it could be a good thing to give it the same value as EXIT_SUCCESS (from cstdlib) because this value is not always zero. However, that's ok for me. Best, Cédric - Mail original - De: Jed Brown j...@jedbrown.org À: Cedric Doucet cedric.dou...@inria.fr, petsc-users@mcs.anl.gov Envoyé: Lundi 25 Août 2014 18:47:25 Objet: Re: [petsc-users] Error and success codes Cedric Doucet cedric.dou...@inria.fr writes: Hello, I want to manage errors with CHKERRQ macro in void functions. I do not want to use CHKERRV. I prefer to modify void functions so that they return an error code. However, it seems CHKERRQ returns a value in case of failure only. Example below does not seem to compile without warning (Wreturn-type flag): -- PetscErrorCode foo() { PetscErrorCode code = somePetscFunction(); CHKERRQ(code); } -- I guess I need to return a success code like this: -- PetscErrorCode foo() { PetscErrorCode code = somePetscFunction(); CHKERRQ(code); return PETSC_SUCCESS_CODE; } -- However, I do not know the value of the success code of Petsc. I guess it is zero but I would prefer to use a macro sucha as PETSC_SUCCESS_CODE in the above example. Does such a macro exist? No, use 0. It's less typing and that is something that will definitely never change.
[petsc-users] Error and success codes
Hello, I want to manage errors with CHKERRQ macro in void functions. I do not want to use CHKERRV. I prefer to modify void functions so that they return an error code. However, it seems CHKERRQ returns a value in case of failure only. Example below does not seem to compile without warning (Wreturn-type flag): -- PetscErrorCode foo() { PetscErrorCode code = somePetscFunction(); CHKERRQ(code); } -- I guess I need to return a success code like this: -- PetscErrorCode foo() { PetscErrorCode code = somePetscFunction(); CHKERRQ(code); return PETSC_SUCCESS_CODE; } -- However, I do not know the value of the success code of Petsc. I guess it is zero but I would prefer to use a macro sucha as PETSC_SUCCESS_CODE in the above example. Does such a macro exist? Best, Cédric
[petsc-users] Optional arguments of MatZeroRows
Hello, I want to use MatZeroRows function ( http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatZeroRows.html ). It is said in the documentation that the last two arguments are optional, i.e. x and b vectors: PetscErrorCode MatZeroRows(Mat mat,PetscInt numRows,const PetscInt rows[],PetscScalar diag, Vec x , Vec b ) However, a call to MatZeroRows(mat,numRows,rows,diag) does not seem to work because the last two input arguments are required. In examples, e.g. src/ksp/ksp/examples/tutorials/ex3.c.html , it seems that optional arguments are passed by putting some zero values instead of vectors: MatZeroRows(mat,numRows,rows,diag, 0 , 0 ) Is this the right way to use MatZeroRows function when one does not want to pass x and b vectors as input arguments? Best, Cédric
Re: [petsc-users] Optional arguments of MatZeroRows
It seems that MatZeroRows(mat,numRows,rows,diag, NULL , NULL ) also works. Is it better to pass NULL instead of 0? Cédric - Mail original - De: Cedric Doucet cedric.dou...@inria.fr À: petsc-users@mcs.anl.gov Envoyé: Mercredi 13 Août 2014 10:09:40 Objet: [petsc-users] Optional arguments of MatZeroRows Hello, I want to use MatZeroRows function ( http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatZeroRows.html ). It is said in the documentation that the last two arguments are optional, i.e. x and b vectors: PetscErrorCode MatZeroRows(Mat mat,PetscInt numRows,const PetscInt rows[],PetscScalar diag, Vec x , Vec b ) However, a call to MatZeroRows(mat,numRows,rows,diag) does not seem to work because the last two input arguments are required. In examples, e.g. src/ksp/ksp/examples/tutorials/ex3.c.html , it seems that optional arguments are passed by putting some zero values instead of vectors: MatZeroRows(mat,numRows,rows,diag, 0 , 0 ) Is this the right way to use MatZeroRows function when one does not want to pass x and b vectors as input arguments? Best, Cédric
Re: [petsc-users] Optional arguments of MatZeroRows
Hi Karl, thank you very much for your answer! Ok, I understand! So, I will pass NULL instead of 0. :-) Best, Cédric - Mail original - De: Karl Rupp r...@iue.tuwien.ac.at À: Cedric Doucet cedric.dou...@inria.fr, petsc-users@mcs.anl.gov Envoyé: Mercredi 13 Août 2014 10:20:55 Objet: Re: [petsc-users] Optional arguments of MatZeroRows Hi Cedric, I want to use MatZeroRows function (http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatZeroRows.html). It is said in the documentation that the last two arguments are optional, i.e. x and b vectors: /PetscErrorCode MatZeroRows(Mat mat,PetscInt numRows,const PetscInt rows[],PetscScalar diag,*Vec x*,*Vec*/*b*) However, a call to /MatZeroRows(mat,numRows,rows,diag)/ does not seem to work because the last two input arguments are required. In examples, e.g. src/ksp/ksp/examples/tutorials/ex3.c.html http://www.mcs.anl.gov/petsc/petsc-current/src/ksp/ksp/examples/tutorials/ex3.c.html, it seems that optional arguments are passed by putting some zero values instead of vectors: /MatZeroRows(mat,numRows,rows,diag,*0*,*0*)/ Is this the right way to use MatZeroRows function when one does not want to pass x and b vectors as input arguments? Yes, in PETSc language an optional argument is an argument for which one can pass NULL (or equivalent). This is because C does not support function overloading, so you always have to pass the full number of arguments. Best regards, Karli
[petsc-users] Correct usage of CHKERRXX
Hello, I need to call several functions from Petsc in a C++ code. I would like to handle manage errors from Petsc with exceptions. In Petsc's documentation, I found that there exists a macro to do that : CHKERRXX. How does it work? Which kind of exception does it throw in case of failure? Do you inherit from std::exception? Is there an exception for each error code? Best, Cédric
Re: [petsc-users] Correct usage of CHKERRXX
Hi Karl, thank you very much for your answer! I will implement a wrapper for handling petsc error codes using the html page you mention. Have a nice day! Cédric - Mail original - De: Karl Rupp r...@iue.tuwien.ac.at À: Cedric Doucet cedric.dou...@inria.fr, petsc-users@mcs.anl.gov Envoyé: Vendredi 8 Août 2014 14:16:25 Objet: Re: [petsc-users] Correct usage of CHKERRXX Hi Cedric, I need to call several functions from Petsc in a C++ code. I would like to handle manage errors from Petsc with exceptions. In Petsc's documentation, I found that there exists a macro to do that : CHKERRXX. How does it work? It checks for a nonzero error code and returns from the function immediately if that is the case. Have a look at the implementation here: http://www.mcs.anl.gov/petsc/petsc-3.5/include/petscerror.h.html Which kind of exception does it throw in case of failure? Do you inherit from std::exception? Is there an exception for each error code? Neither. You would have to write your own wrapper around it, translating the error codes into exceptions. PETSc cannot use exceptions since it is a C library. Some people also argue against exceptions because they tend to bloat the executable for all the roll-back code. Best regards, Karli
[petsc-users] Assignement operator overloading for vectors
Hello, I need to overload the assignement operator for a C++ class which has a Petsc vector as a data member: class Foo { public: Foo operator=(Foo const copy); private: Vec m_vec; }; The algorithm for overloading the assignement operator should look like this : Foo Foo::operator=(Foo const copy) { if ( this != copy ) { // destroy this-m_vec // allocate this-m_vec with the same size as copy.m_vec's size // copy the content of copy.m_vec into this-m_vec } return *this; } I thought that VecCopy(copy.m_vec,m_vec) does everything I need but I have an error during the execution. So I tried to call first VecDuplicate(copy.m_vec,m_vec) and then VecCopy(copy.m_vec,m_vec) but I still have an error. How shoud assignement operator overloading be implemented? Do I have to call VecDestroy before calling VecDuplicate? Must input vectors have the same size in VecCopy? Thank you very much for your help! Best regards, Cédric Doucet
Re: [petsc-users] Assignement operator overloading for vectors
I have the same error in copy contructor : Foo::Foo(Foo const copy) { VecDuplicate(copy.m_vec,m_vec); VecCopy(copy.m_vec,m_vec); } What am I doing wrong here? Cédric - Mail original - De: Cedric Doucet cedric.dou...@inria.fr À: petsc-users@mcs.anl.gov Envoyé: Jeudi 19 Juin 2014 14:14:39 Objet: Assignement operator overloading for vectors Hello, I need to overload the assignement operator for a C++ class which has a Petsc vector as a data member: class Foo { public: Foo operator=(Foo const copy); private: Vec m_vec; }; The algorithm for overloading the assignement operator should look like this : Foo Foo::operator=(Foo const copy) { if ( this != copy ) { // destroy this-m_vec // allocate this-m_vec with the same size as copy.m_vec's size // copy the content of copy.m_vec into this-m_vec } return *this; } I thought that VecCopy(copy.m_vec,m_vec) does everything I need but I have an error during the execution. So I tried to call first VecDuplicate(copy.m_vec,m_vec) and then VecCopy(copy.m_vec,m_vec) but I still have an error. How shoud assignement operator overloading be implemented? Do I have to call VecDestroy before calling VecDuplicate? Must input vectors have the same size in VecCopy? Thank you very much for your help! Best regards, Cédric Doucet
[petsc-users] Partitioner in DMPlexDistribute
Hello, I have just downloaded Petsc 3.4.4 and I have looked at plex.c file. In DMPlexDistribute, I cannot see where partitioner input argument is used. Is METIS used by default? Best regards, Cédric Doucet INRIA Paris-Rocquencourt France
Re: [petsc-users] Partitioner in DMPlexDistribute
Hello, thank you very much for your answer. When do you plan to put this functionality in a stable release? Best, Cédric - Mail original - De: Matthew Knepley knep...@gmail.com À: Cedric Doucet cedric.dou...@inria.fr Cc: petsc-users@mcs.anl.gov Envoyé: Vendredi 4 Avril 2014 14:28:53 Objet: Re: [petsc-users] Partitioner in DMPlexDistribute On Fri, Apr 4, 2014 at 6:09 AM, Cedric Doucet cedric.dou...@inria.fr wrote: Hello, I have just downloaded Petsc 3.4.4 and I have looked at plex.c file. In DMPlexDistribute, I cannot see where partitioner input argument is used. Is METIS used by default? In 3.4.4, the name is just a placeholder, and it users Chaco by default, and then ParMetis. In master, it does use the name to select the preconditioner. If you use Plex, I recommend using master. Thanks, Matt Best regards, Cédric Doucet INRIA Paris-Rocquencourt France -- 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
Re: [petsc-users] Input arguments of DMPlexCreateFromDAG
Thank you for your answer. I understand well the reason why coneSize begins with faces of cells and vertices first. However, I am not sure to understand how cone points are numbered in the definition of start. For example, in CreateSimplex2D in ex5.c (two triangles sharing an edge), we have: PetscInt numPoints[3] = {4, 5, 2}; PetscInt coneSize[11] = {3, 3, 0, 0, 0, 0, 2, 2, 2, 2, 2}; PetscInt cones[16] = {6, 7, 8, 9, 7, 10, 2, 3, 3, 4, 4, 2, 5, 4, 3, 5}; PetscInt coneOrientations[16] = {0, 0, 0, 0, -2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; PetscScalar vertexCoords[8] = {-0.5, 0.5, 0.0, 0.0, 0.0, 1.0, 0.5, 0.5}; The fact that coneOrientations[4] equals -2 means that edge cones[4]=7 must be oriented in reverse order starting at vertex 1. However, edge 7 is defined by vertices (3,4). Does it mean that a local numbering is used here: (3,4)~(v0,v1)? In algebraic topology, a convenient way to orient simplices is to number their vertices in ascendant order. For example, an edge (i,j) is oriented so that ij, a face (i,j,k) is oriented so that ijk, etc. Can we adopt the same convention here and does it simplify something? Best regards, Cédric Doucet - Mail original - De: Matthew Knepley knep...@gmail.com À: Cedric Doucet cedric.dou...@inria.fr Cc: petsc-users@mcs.anl.gov Envoyé: Jeudi 30 Janvier 2014 19:26:36 Objet: Re: [petsc-users] Input arguments of DMPlexCreateFromDAG On Thu, Jan 30, 2014 at 12:19 PM, Cedric Doucet cedric.dou...@inria.fr wrote: Hello, I tried to use DMPlexCreateFromDAG function to create a DM structure from a hybrid mesh. To understand how it works, I look at ex5.c file. Unfortunately, there are some things that I do not understand. 1. Why does coneSize lists faces of cells first, then faces of vertices and finally faces of edges (in 2D)? Listing faces of vertices, then faces of edges and finally faces of cells is not simpler? This is really about what order you number points. I wanted to support meshes with just cells and vertices, as well as those with face and edges. I also wanted to be able to convert between them. Thus it made sense to leave the cell and vertex numbers invariant under this change. I still think this is the best pragmatic alternative. 2 What does coneOrientations contain? For two counterclockwise oriented triangles sharing an edge e={v0,v1}, I understand that {v0,v1} is the right oriented edge for the second triangle (and e for the first one) but what is the meaning of value -2? I read that it is -(o+1) with o=1 but why does o equal 1 in this case? Right now, orientation o = signstart means: sign: + means traverse in cone order - means traverse in the reverse of cone order start: cone point to start iteration on if sign is -, then start on point -(start+1) Thus -2 means start on point 1 and go in reverse order, so for an edge that would be {1, 0} which is what you want. What we should really have is start identify a group element from the symmetry group of the point, and sign indicate inversion. However, that will be a big rewrite and needs to be motivated by applications. Matt Thank you very much for your help! Best regards, Cédric Doucet -- 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
Re: [petsc-users] Input arguments of DMPlexCreateFromDAG
Hello, DMPlexInterpolate is very interesting! Is it slow? If I want to call DMplexInterpolate, just after DMPlexCreateFromDAG call, for the example of two triangles sharing an edge, I only have to specify cells and vertices like this in DMPlexCreateFromDAG: PetscInt numPoints[3] = {4, 0, 2}; PetscInt coneSize[11] = {3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0}; PetscScalar vertexCoords[8] = {-0.5, 0.5, 0.0, 0.0, 0.0, 1.0, 0.5, 0.5}; and let cones and coneOrientations be empty? Cédric - Mail original - De: Matthew Knepley knep...@gmail.com À: Cedric Doucet cedric.dou...@inria.fr Cc: petsc-users@mcs.anl.gov Envoyé: Vendredi 31 Janvier 2014 12:21:40 Objet: Re: [petsc-users] Input arguments of DMPlexCreateFromDAG On Fri, Jan 31, 2014 at 3:23 AM, Cedric Doucet cedric.dou...@inria.fr wrote: Thank you for your answer. I understand well the reason why coneSize begins with faces of cells and vertices first. However, I am not sure to understand how cone points are numbered in the definition of start. For example, in CreateSimplex2D in ex5.c (two triangles sharing an edge), we have: PetscInt numPoints[3] = {4, 5, 2}; PetscInt coneSize[11] = {3, 3, 0, 0, 0, 0, 2, 2, 2, 2, 2}; PetscInt cones[16] = {6, 7, 8, 9, 7, 10, 2, 3, 3, 4, 4, 2, 5, 4, 3, 5}; PetscInt coneOrientations[16] = {0, 0, 0, 0, -2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; PetscScalar vertexCoords[8] = {-0.5, 0.5, 0.0, 0.0, 0.0, 1.0, 0.5, 0.5}; The fact that coneOrientations[4] equals -2 means that edge cones[4]=7 must be oriented in reverse order starting at vertex 1. However, edge 7 is defined by vertices (3,4). Does it mean that a local numbering is used here: (3,4)~(v0,v1)? Yes, exactly the numbering from cones[8-9]. In algebraic topology, a convenient way to orient simplices is to number their vertices in ascendant order. For example, an edge (i,j) is oriented so that ij, a face (i,j,k) is oriented so that ijk, etc. Can we adopt the same convention here and does it simplify something? No, because we do not have exclusively simplices. You can simplify by only specifying cells and vertices, which need no orientations, and then calling DMPlexInterpolate(). Matt Best regards, Cédric Doucet De: Matthew Knepley knep...@gmail.com À: Cedric Doucet cedric.dou...@inria.fr Cc: petsc-users@mcs.anl.gov Envoyé: Jeudi 30 Janvier 2014 19:26:36 Objet: Re: [petsc-users] Input arguments of DMPlexCreateFromDAG On Thu, Jan 30, 2014 at 12:19 PM, Cedric Doucet cedric.dou...@inria.fr wrote: Hello, I tried to use DMPlexCreateFromDAG function to create a DM structure from a hybrid mesh. To understand how it works, I look at ex5.c file. Unfortunately, there are some things that I do not understand. 1. Why does coneSize lists faces of cells first, then faces of vertices and finally faces of edges (in 2D)? Listing faces of vertices, then faces of edges and finally faces of cells is not simpler? This is really about what order you number points. I wanted to support meshes with just cells and vertices, as well as those with face and edges. I also wanted to be able to convert between them. Thus it made sense to leave the cell and vertex numbers invariant under this change. I still think this is the best pragmatic alternative. 2 What does coneOrientations contain? For two counterclockwise oriented triangles sharing an edge e={v0,v1}, I understand that {v0,v1} is the right oriented edge for the second triangle (and e for the first one) but what is the meaning of value -2? I read that it is -(o+1) with o=1 but why does o equal 1 in this case? Right now, orientation o = signstart means: sign: + means traverse in cone order - means traverse in the reverse of cone order start: cone point to start iteration on if sign is -, then start on point -(start+1) Thus -2 means start on point 1 and go in reverse order, so for an edge that would be {1, 0} which is what you want. What we should really have is start identify a group element from the symmetry group of the point, and sign indicate inversion. However, that will be a big rewrite and needs to be motivated by applications. Matt Thank you very much for your help! Best regards, Cédric Doucet -- 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 -- What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments
Re: [petsc-users] Input arguments of DMPlexCreateFromDAG
Thank you very much for your help! I will test this solution. Best regards, Cédric - Mail original - De: Matthew Knepley knep...@gmail.com À: Cedric Doucet cedric.dou...@inria.fr Cc: petsc-users@mcs.anl.gov Envoyé: Vendredi 31 Janvier 2014 13:11:14 Objet: Re: [petsc-users] Input arguments of DMPlexCreateFromDAG On Fri, Jan 31, 2014 at 5:55 AM, Cedric Doucet cedric.dou...@inria.fr wrote: Hello, DMPlexInterpolate is very interesting! Is it slow? It is as fast as I know how to make it. It uses hashing to find the matches. If I want to call DMplexInterpolate, just after DMPlexCreateFromDAG call, for the example of two triangles sharing an edge, I only have to specify cells and vertices like this in DMPlexCreateFromDAG: PetscInt numPoints[3] = {4, 0, 2}; PetscInt coneSize[11] = {3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0}; PetscScalar vertexCoords[8] = {-0.5, 0.5, 0.0, 0.0, 0.0, 1.0, 0.5, 0.5}; and let cones and coneOrientations be empty? cones[] would be the vertices in each cell, and coneOrientations would be all zeros. Matt Cédric De: Matthew Knepley knep...@gmail.com À: Cedric Doucet cedric.dou...@inria.fr Cc: petsc-users@mcs.anl.gov Envoyé: Vendredi 31 Janvier 2014 12:21:40 Objet: Re: [petsc-users] Input arguments of DMPlexCreateFromDAG On Fri, Jan 31, 2014 at 3:23 AM, Cedric Doucet cedric.dou...@inria.fr wrote: Thank you for your answer. I understand well the reason why coneSize begins with faces of cells and vertices first. However, I am not sure to understand how cone points are numbered in the definition of start. For example, in CreateSimplex2D in ex5.c (two triangles sharing an edge), we have: PetscInt numPoints[3] = {4, 5, 2}; PetscInt coneSize[11] = {3, 3, 0, 0, 0, 0, 2, 2, 2, 2, 2}; PetscInt cones[16] = {6, 7, 8, 9, 7, 10, 2, 3, 3, 4, 4, 2, 5, 4, 3, 5}; PetscInt coneOrientations[16] = {0, 0, 0, 0, -2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; PetscScalar vertexCoords[8] = {-0.5, 0.5, 0.0, 0.0, 0.0, 1.0, 0.5, 0.5}; The fact that coneOrientations[4] equals -2 means that edge cones[4]=7 must be oriented in reverse order starting at vertex 1. However, edge 7 is defined by vertices (3,4). Does it mean that a local numbering is used here: (3,4)~(v0,v1)? Yes, exactly the numbering from cones[8-9]. In algebraic topology, a convenient way to orient simplices is to number their vertices in ascendant order. For example, an edge (i,j) is oriented so that ij, a face (i,j,k) is oriented so that ijk, etc. Can we adopt the same convention here and does it simplify something? No, because we do not have exclusively simplices. You can simplify by only specifying cells and vertices, which need no orientations, and then calling DMPlexInterpolate(). Matt Best regards, Cédric Doucet De: Matthew Knepley knep...@gmail.com À: Cedric Doucet cedric.dou...@inria.fr Cc: petsc-users@mcs.anl.gov Envoyé: Jeudi 30 Janvier 2014 19:26:36 Objet: Re: [petsc-users] Input arguments of DMPlexCreateFromDAG On Thu, Jan 30, 2014 at 12:19 PM, Cedric Doucet cedric.dou...@inria.fr wrote: Hello, I tried to use DMPlexCreateFromDAG function to create a DM structure from a hybrid mesh. To understand how it works, I look at ex5.c file. Unfortunately, there are some things that I do not understand. 1. Why does coneSize lists faces of cells first, then faces of vertices and finally faces of edges (in 2D)? Listing faces of vertices, then faces of edges and finally faces of cells is not simpler? This is really about what order you number points. I wanted to support meshes with just cells and vertices, as well as those with face and edges. I also wanted to be able to convert between them. Thus it made sense to leave the cell and vertex numbers invariant under this change. I still think this is the best pragmatic alternative. 2 What does coneOrientations contain? For two counterclockwise oriented triangles sharing an edge e={v0,v1}, I understand that {v0,v1} is the right oriented edge for the second triangle (and e for the first one) but what is the meaning of value -2? I read that it is -(o+1) with o=1 but why does
[petsc-users] Input arguments of DMPlexCreateFromDAG
Hello, I tried to use DMPlexCreateFromDAG function to create a DM structure from a hybrid mesh. To understand how it works, I look at ex5.c file. Unfortunately, there are some things that I do not understand. 1. Why does coneSize lists faces of cells first, then faces of vertices and finally faces of edges (in 2D)? Listing faces of vertices, then faces of edges and finally faces of cells is not simpler? 2 What does coneOrientations contain? For two counterclockwise oriented triangles sharing an edge e={v0,v1}, I understand that {v0,v1} is the right oriented edge for the second triangle (and e for the first one) but what is the meaning of value -2? I read that it is -(o+1) with o=1 but why does o equal 1 in this case? Thank you very much for your help! Best regards, Cédric Doucet
Re: [petsc-users] DMPlexCreateFromCellList and hybrid meshes
Hello, sorry, we talked about it few months ago. For the moment, it is assumed in DMPlexCreateFromCellList function that cells have all the same number of vertices. In other words, it means that meshes containing one and only one type of cell (from a topological viewpoint) can be handled by this function only. However, several mesh generators are able to discretize geometries by means of different kinds of cells. Resulting meshes are said to be mixed or hybrid because they contain different types of cells. To create a DMPlex structure from such a mesh, one needs to slightly modify DMPlexCreateFromCellList prototype. To my mind, the simplest way to do that is to redefine numCorners as an integer array instead of a simple integer value. Its length should be numCells and it should contain the number of vertices for each cell. Note that the length of cells parameter should be modified as well. But, of course, if you have a better idea about the new prototype, it's ok for me. Best regards, Cédric Doucet - Mail original - De: Matthew Knepley knep...@gmail.com À: Cedric Doucet cedric.dou...@inria.fr Cc: petsc-users@mcs.anl.gov Envoyé: Jeudi 2 Janvier 2014 17:01:24 Objet: Re: [petsc-users] DMPlexCreateFromCellList and hybrid meshes On Thu, Jan 2, 2014 at 8:08 AM, Cedric Doucet cedric.dou...@inria.fr wrote: Hello, indeed, I need to have a generalized version of DMPlexCreateFromCellList function which can take an hybrid mesh as an input parameter. What interface? Modern mesh generators often provide mixed generation functionalities (e.g. gmsh which can generate pyramids and prisms). As a matter of fact, cells are never numbered independently of vertices in hybrid meshes because different generators are used (structured and unstructured ones). From a practical point of view, it is far much easier to let each generator number its own cells without renumbering shared vertices. Therefore, cells of hybrid meshes are sorted in a canonical way: cells of generator 1, cells of generator 2, etc. I don't understand what you want here. Its imprecise. Matt I deeply think that this new version is very useful for real-life applications. Please let me know when this new version will be available. Thank you very much, Cédric Doucet De: Matthew Knepley knep...@gmail.com À: Cedric Doucet cedric.dou...@inria.fr Cc: petsc-users@mcs.anl.gov Envoyé: Jeudi 31 Octobre 2013 14:13:14 Objet: Re: [petsc-users] DMPlexCreateFromCellList and hybrid meshes On Thu, Oct 31, 2013 at 5:20 AM, Cedric Doucet cedric.dou...@inria.fr wrote: Thank you very much for your help. Do you plan to add this code to Petsc? It would be better for us to call an official Petsc function than maintaining a Petsc-style code into our C++ software. If this is really what you need, then I will put it in. However, I intended this to be used primarily for mesh generators, since they tend to number cells and vertices independently and have the int and double types hardwired. If you are writing your own code, please consider DMPlexCreateFromDAG() which has the flexibility for cell topology that you want. The main differences are that it uses PETSc types and a single contiguous numbering. Would this work for you? Thanks, Matt Best regards, Cédric Doucet De: Matthew Knepley knep...@gmail.com À: Cedric Doucet cedric.dou...@inria.fr Cc: petsc-users@mcs.anl.gov Envoyé: Mardi 29 Octobre 2013 17:24:03 Objet: Re: [petsc-users] DMPlexCreateFromCellList and hybrid meshes On Tue, Oct 29, 2013 at 10:24 AM, Cedric Doucet cedric.dou...@inria.fr wrote: Hello, I have a short question about the code I need to modify. As far as I understand, numCorner should be replaced by an array numCorners[numCells] containing the number of vertices of each cell. The body of DMPlexBuildFromCellList_Private function becomes --- ierr = DMPlexSetChart(dm, 0, numCells+numVertices);CHKERRQ(ierr); maxCorners = 0; for (c = 0; c numCells; ++c) { ierr = DMPlexSetConeSize(dm, c, numCorners[c]);CHKERRQ(ierr); maxCorners = PetscMax(maxCorners, numCorners[c]); } ierr = DMSetUp(dm);CHKERRQ(ierr); ierr
Re: [petsc-users] DMPlexCreateFromCellList and hybrid meshes
I could use DMPlexCreateFromDAG but there are several drawbacks: 1. DMPlexCreateFromDAG is not well documented; 2. other developers will have to understand a tricky data structure (DAG) to modify my code (see point 1 to understand why it is a problem);; 3. DMPlexCreateFromDAG looks like a low-level function in comparison with DMPlexCreateFromCellList which acts at a higher level: if you modify this structure, I or someone else will have to modify my code (see point 2 to understand why it is a problem); You proposed to modify DMPlexCreateFromCellList function for me and I decided to accept it after thinking about it. Did you change your mind? - Mail original - De: Jed Brown jedbr...@mcs.anl.gov À: Cedric Doucet cedric.dou...@inria.fr, Matthew Knepley knep...@gmail.com Cc: petsc-users@mcs.anl.gov Envoyé: Vendredi 3 Janvier 2014 16:31:57 Objet: Re: [petsc-users] DMPlexCreateFromCellList and hybrid meshes Cedric Doucet cedric.dou...@inria.fr writes: Hello, sorry, we talked about it few months ago. For the moment, it is assumed in DMPlexCreateFromCellList function that cells have all the same number of vertices. In other words, it means that meshes containing one and only one type of cell (from a topological viewpoint) can be handled by this function only. However, several mesh generators are able to discretize geometries by means of different kinds of cells. Resulting meshes are said to be mixed or hybrid because they contain different types of cells. To create a DMPlex structure from such a mesh, one needs to slightly modify DMPlexCreateFromCellList prototype. Why can't you use DMPlexCreateFromDAG? You can create a non-interpolated mesh and interpolate it later if you want. Note that even for non-interpolated meshes, you often need boundary faces, in which case DMPlexCreateFromCellList would still not be sufficient.
Re: [petsc-users] DMPlexCreateFromCellList and hybrid meshes
Hello, indeed, I need to have a generalized version of DMPlexCreateFromCellList function which can take an hybrid mesh as an input parameter. Modern mesh generators often provide mixed generation functionalities (e.g. gmsh which can generate pyramids and prisms). As a matter of fact, cells are never numbered independently of vertices in hybrid meshes because different generators are used (structured and unstructured ones). From a practical point of view, it is far much easier to let each generator number its own cells without renumbering shared vertices. Therefore, cells of hybrid meshes are sorted in a canonical way: cells of generator 1, cells of generator 2, etc. I deeply think that this new version is very useful for real-life applications. Please let me know when this new version will be available. Thank you very much, Cédric Doucet - Mail original - De: Matthew Knepley knep...@gmail.com À: Cedric Doucet cedric.dou...@inria.fr Cc: petsc-users@mcs.anl.gov Envoyé: Jeudi 31 Octobre 2013 14:13:14 Objet: Re: [petsc-users] DMPlexCreateFromCellList and hybrid meshes On Thu, Oct 31, 2013 at 5:20 AM, Cedric Doucet cedric.dou...@inria.fr wrote: Thank you very much for your help. Do you plan to add this code to Petsc? It would be better for us to call an official Petsc function than maintaining a Petsc-style code into our C++ software. If this is really what you need, then I will put it in. However, I intended this to be used primarily for mesh generators, since they tend to number cells and vertices independently and have the int and double types hardwired. If you are writing your own code, please consider DMPlexCreateFromDAG() which has the flexibility for cell topology that you want. The main differences are that it uses PETSc types and a single contiguous numbering. Would this work for you? Thanks, Matt Best regards, Cédric Doucet De: Matthew Knepley knep...@gmail.com À: Cedric Doucet cedric.dou...@inria.fr Cc: petsc-users@mcs.anl.gov Envoyé: Mardi 29 Octobre 2013 17:24:03 Objet: Re: [petsc-users] DMPlexCreateFromCellList and hybrid meshes On Tue, Oct 29, 2013 at 10:24 AM, Cedric Doucet cedric.dou...@inria.fr wrote: Hello, I have a short question about the code I need to modify. As far as I understand, numCorner should be replaced by an array numCorners[numCells] containing the number of vertices of each cell. The body of DMPlexBuildFromCellList_Private function becomes --- ierr = DMPlexSetChart(dm, 0, numCells+numVertices);CHKERRQ(ierr); maxCorners = 0; for (c = 0; c numCells; ++c) { ierr = DMPlexSetConeSize(dm, c, numCorners[c]);CHKERRQ(ierr); maxCorners = PetscMax(maxCorners, numCorners[c]); } ierr = DMSetUp(dm);CHKERRQ(ierr); ierr = DMGetWorkArray(dm, maxCorners, PETSC_INT, cone);CHKERRQ(ierr); for (c = 0, off = 0; c numCells; ++c) { for (p = 0; p numCorners[c]; ++p) { cone[p] = cells[off+p]+numCells; } ierr = DMPlexSetCone(dm, c, cone);CHKERRQ(ierr); off += numCorners[c]; } ierr = DMRestoreWorkArray(dm, maxCorners, PETSC_INT, cone);CHKERRQ(ierr); ierr = DMPlexSymmetrize(dm);CHKERRQ(ierr); ierr = DMPlexStratify(dm);CHKERRQ(ierr); Matt -- However, I am not quite sure that DMGetWorkArray and DMRestoreWorkArray should be used like this. I guess that DMRestoreWorkArray behaves like free function in ansi c but I am not sure. Do you think that calling DMGetWorkArray and DMRestoreWorkArray inside a loop is a good thing from the point of view of computational time and memory management? Note: the best way to do this may be to first sort cells by numCorners to avoid many calls to DMGetWorkArray and DMRestoreWorkArray. This is actually what I have in my own code but I would like to maintain Petsc's philosophy. Thanks, Cédric De: Matthew Knepley knep...@gmail.com À: Cedric Doucet cedric.dou...@inria.fr Cc: petsc-users@mcs.anl.gov Envoyé: Vendredi 25 Octobre 2013 16:31:59 Objet: Re: [petsc-users] DMPlexCreateFromCellList and hybrid meshes On Fri, Oct 25, 2013 at 7:23 AM, Cedric Doucet cedric.dou...@inria.fr wrote: Hello
Re: [petsc-users] DMPlexCreateFromCellList and hybrid meshes
Thank you very much for your help. Do you plan to add this code to Petsc? It would be better for us to call an official Petsc function than maintaining a Petsc-style code into our C++ software. Best regards, Cédric Doucet - Mail original - De: Matthew Knepley knep...@gmail.com À: Cedric Doucet cedric.dou...@inria.fr Cc: petsc-users@mcs.anl.gov Envoyé: Mardi 29 Octobre 2013 17:24:03 Objet: Re: [petsc-users] DMPlexCreateFromCellList and hybrid meshes On Tue, Oct 29, 2013 at 10:24 AM, Cedric Doucet cedric.dou...@inria.fr wrote: Hello, I have a short question about the code I need to modify. As far as I understand, numCorner should be replaced by an array numCorners[numCells] containing the number of vertices of each cell. The body of DMPlexBuildFromCellList_Private function becomes --- ierr = DMPlexSetChart(dm, 0, numCells+numVertices);CHKERRQ(ierr); maxCorners = 0; for (c = 0; c numCells; ++c) { ierr = DMPlexSetConeSize(dm, c, numCorners[c]);CHKERRQ(ierr); maxCorners = PetscMax(maxCorners, numCorners[c]); } ierr = DMSetUp(dm);CHKERRQ(ierr); ierr = DMGetWorkArray(dm, maxCorners, PETSC_INT, cone);CHKERRQ(ierr); for (c = 0, off = 0; c numCells; ++c) { for (p = 0; p numCorners[c]; ++p) { cone[p] = cells[off+p]+numCells; } ierr = DMPlexSetCone(dm, c, cone);CHKERRQ(ierr); off += numCorners[c]; } ierr = DMRestoreWorkArray(dm, maxCorners, PETSC_INT, cone);CHKERRQ(ierr); ierr = DMPlexSymmetrize(dm);CHKERRQ(ierr); ierr = DMPlexStratify(dm);CHKERRQ(ierr); Matt -- However, I am not quite sure that DMGetWorkArray and DMRestoreWorkArray should be used like this. I guess that DMRestoreWorkArray behaves like free function in ansi c but I am not sure. Do you think that calling DMGetWorkArray and DMRestoreWorkArray inside a loop is a good thing from the point of view of computational time and memory management? Note: the best way to do this may be to first sort cells by numCorners to avoid many calls to DMGetWorkArray and DMRestoreWorkArray. This is actually what I have in my own code but I would like to maintain Petsc's philosophy. Thanks, Cédric De: Matthew Knepley knep...@gmail.com À: Cedric Doucet cedric.dou...@inria.fr Cc: petsc-users@mcs.anl.gov Envoyé: Vendredi 25 Octobre 2013 16:31:59 Objet: Re: [petsc-users] DMPlexCreateFromCellList and hybrid meshes On Fri, Oct 25, 2013 at 7:23 AM, Cedric Doucet cedric.dou...@inria.fr wrote: Hello, I've noticed that DMPlexCreateFromCellList assumes that cells have the same number of vertices (numcorners argument). What should be done when one wants to create a DMPlex from a mesh containing different types of cells? Does one have to create several DMPlex structures and merge them? Does one have to create a unique DMPlex by hand? The code is very short: ierr = DMPlexSetChart(dm, 0, numCells+numVertices);CHKERRQ(ierr); for (c = 0; c numCells; ++c) { ierr = DMPlexSetConeSize(dm, c, numCorners);CHKERRQ(ierr); } ierr = DMSetUp(dm);CHKERRQ(ierr); ierr = DMGetWorkArray(dm, numCorners, PETSC_INT, cone);CHKERRQ(ierr); for (c = 0; c numCells; ++c) { for (p = 0; p numCorners; ++p) { cone[p] = cells[c*numCorners+p]+numCells; } ierr = DMPlexSetCone(dm, c, cone);CHKERRQ(ierr); } ierr = DMRestoreWorkArray(dm, numCorners, PETSC_INT, cone);CHKERRQ(ierr); ierr = DMPlexSymmetrize(dm);CHKERRQ(ierr); ierr = DMPlexStratify(dm);CHKERRQ(ierr); This code is all in plexcreate.c. If you want different cells, you can change numCorners for each cell. I could make a convenience form if necessary. Matt Thank you very much for your help. Cédric -- 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 -- 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
Re: [petsc-users] DMPlexCreateFromCellList and hybrid meshes
Hello, I have a short question about the code I need to modify. As far as I understand, numCorner should be replaced by an array numCorners[numCells] containing the number of vertices of each cell. The body of DMPlexBuildFromCellList_Private function becomes --- ierr = DMPlexSetChart(dm, 0, numCells+numVertices);CHKERRQ(ierr); for (c = 0; c numCells; ++c) { ierr = DMPlexSetConeSize(dm, c, numCorners[c]);CHKERRQ(ierr); } ierr = DMSetUp(dm);CHKERRQ(ierr); for (c = 0; c numCells; ++c) { ierr = DMGetWorkArray(dm, numCorners, PETSC_INT, cone);CHKERRQ(ierr); for (p = 0; p numCorners[c]; ++p) { cone[p] = cells[c*numCorners[c]+p]+numCells; } ierr = DMRestoreWorkArray(dm, numCorners, PETSC_INT, cone);CHKERRQ(ierr); ierr = DMPlexSetCone(dm, c, cone);CHKERRQ(ierr); } ierr = DMPlexSymmetrize(dm);CHKERRQ(ierr); ierr = DMPlexStratify(dm);CHKERRQ(ierr); -- However, I am not quite sure that DMGetWorkArray and DMRestoreWorkArray should be used like this. I guess that DMRestoreWorkArray behaves like free function in ansi c but I am not sure. Do you think that calling DMGetWorkArray and DMRestoreWorkArray inside a loop is a good thing from the point of view of computational time and memory management? Note: the best way to do this may be to first sort cells by numCorners to avoid many calls to DMGetWorkArray and DMRestoreWorkArray. This is actually what I have in my own code but I would like to maintain Petsc's philosophy. Thanks, Cédric - Mail original - De: Matthew Knepley knep...@gmail.com À: Cedric Doucet cedric.dou...@inria.fr Cc: petsc-users@mcs.anl.gov Envoyé: Vendredi 25 Octobre 2013 16:31:59 Objet: Re: [petsc-users] DMPlexCreateFromCellList and hybrid meshes On Fri, Oct 25, 2013 at 7:23 AM, Cedric Doucet cedric.dou...@inria.fr wrote: Hello, I've noticed that DMPlexCreateFromCellList assumes that cells have the same number of vertices (numcorners argument). What should be done when one wants to create a DMPlex from a mesh containing different types of cells? Does one have to create several DMPlex structures and merge them? Does one have to create a unique DMPlex by hand? The code is very short: ierr = DMPlexSetChart(dm, 0, numCells+numVertices);CHKERRQ(ierr); for (c = 0; c numCells; ++c) { ierr = DMPlexSetConeSize(dm, c, numCorners);CHKERRQ(ierr); } ierr = DMSetUp(dm);CHKERRQ(ierr); ierr = DMGetWorkArray(dm, numCorners, PETSC_INT, cone);CHKERRQ(ierr); for (c = 0; c numCells; ++c) { for (p = 0; p numCorners; ++p) { cone[p] = cells[c*numCorners+p]+numCells; } ierr = DMPlexSetCone(dm, c, cone);CHKERRQ(ierr); } ierr = DMRestoreWorkArray(dm, numCorners, PETSC_INT, cone);CHKERRQ(ierr); ierr = DMPlexSymmetrize(dm);CHKERRQ(ierr); ierr = DMPlexStratify(dm);CHKERRQ(ierr); This code is all in plexcreate.c. If you want different cells, you can change numCorners for each cell. I could make a convenience form if necessary. Matt Thank you very much for your help. Cédric -- 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
[petsc-users] Partitioner in DMPlexDistribute
Hello, I need to use DMPlexDistribute in a parallel finite element code. I would like to know which partitioner can be used with this function. I saw in an example that chaco is a possibility. I tried to use parmetis instead but I did not manage to do it. Furthermore, I do not see where the input partitioner is used in the source code of DMPlexDistribute. Best regards, Cédric Doucet
Re: [petsc-users] Partitioner in DMPlexDistribute
I was not looking at the latest version of the code (it seems online documentation has not been updated yet). Now, I can see that partitioner is used as an argument of DMPlexCreatePartition. However, there is a new argument: a PetscSF. I have two questions about this new implementation: 1. which partitioner can be used? 2. how to initialize the new PetscSF argument? - Mail original - De: Cedric Doucet cedric.dou...@inria.fr À: petsc-users@mcs.anl.gov Envoyé: Lundi 28 Octobre 2013 11:25:25 Objet: [petsc-users] Partitioner in DMPlexDistribute Hello, I need to use DMPlexDistribute in a parallel finite element code. I would like to know which partitioner can be used with this function. I saw in an example that chaco is a possibility. I tried to use parmetis instead but I did not manage to do it. Furthermore, I do not see where the input partitioner is used in the source code of DMPlexDistribute. Best regards, Cédric Doucet
Re: [petsc-users] Partitioner in DMPlexDistribute
I've just seen in DMPlexCreatePartition that only 'chaco' and 'metis' can be used. - Mail original - De: Cedric Doucet cedric.dou...@inria.fr À: petsc-users@mcs.anl.gov Envoyé: Lundi 28 Octobre 2013 12:17:22 Objet: Re: [petsc-users] Partitioner in DMPlexDistribute I was not looking at the latest version of the code (it seems online documentation has not been updated yet). Now, I can see that partitioner is used as an argument of DMPlexCreatePartition. However, there is a new argument: a PetscSF. I have two questions about this new implementation: 1. which partitioner can be used? 2. how to initialize the new PetscSF argument? - Mail original - De: Cedric Doucet cedric.dou...@inria.fr À: petsc-users@mcs.anl.gov Envoyé: Lundi 28 Octobre 2013 11:25:25 Objet: [petsc-users] Partitioner in DMPlexDistribute Hello, I need to use DMPlexDistribute in a parallel finite element code. I would like to know which partitioner can be used with this function. I saw in an example that chaco is a possibility. I tried to use parmetis instead but I did not manage to do it. Furthermore, I do not see where the input partitioner is used in the source code of DMPlexDistribute. Best regards, Cédric Doucet
[petsc-users] DMPlexCreateFromCellList and hybrid meshes
Hello, I've noticed that DMPlexCreateFromCellList assumes that cells have the same number of vertices (numcorners argument). What should be done when one wants to create a DMPlex from a mesh containing different types of cells? Does one have to create several DMPlex structures and merge them? Does one have to create a unique DMPlex by hand? Thank you very much for your help. Cédric
Re: [petsc-users] Partitioning meshes with DMPlex
Thank you Matt and Jed for your answers! As far as I understand, DMPlexDistribute call DMPlexCreatePartition and is exactly what I am looking for. Cédric - Mail original - De: Matthew Knepley knep...@gmail.com À: Jed Brown jedbr...@mcs.anl.gov Cc: Cedric Doucet cedric.dou...@inria.fr, petsc-users@mcs.anl.gov Envoyé: Jeudi 24 Octobre 2013 00:25:40 Objet: Re: [petsc-users] Partitioning meshes with DMPlex On Wed, Oct 23, 2013 at 10:43 AM, Jed Brown jedbr...@mcs.anl.gov wrote: Cedric Doucet cedric.dou...@inria.fr writes: Hello, what is the best way to partition unstructured meshes stored with DMPlex? You can use DMPlexCreatePartition, which supports metis and chaco. Matt, DMPlexCreatePartition documentation has left out the partitioner name. I assume what you really want is DMPlexDistribute(). Matt Does one have to create an adjacency matrix and use MatPartitioning routines? I do not want to partition the mesh graph (by cutting edges) but having a true domain decomposition (sets of cells per processor). Thank you very much for your help! Best regards, Cédric Doucet -- 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
[petsc-users] Partitioning meshes with DMPlex
Hello, what is the best way to partition unstructured meshes stored with DMPlex? Does one have to create an adjacency matrix and use MatPartitioning routines? I do not want to partition the mesh graph (by cutting edges) but having a true domain decomposition (sets of cells per processor). Thank you very much for your help! Best regards, Cédric Doucet