On Wed, Sep 26, 2012 at 5:37 PM, Chris Eldred <span dir="ltr"><<a href="mailto:chris.eldred@gmail.com" target="_blank">chris.eldred@gmail.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Will there be a way to set coordinates if I am using a homemade mesh generator?<br></blockquote><div><br></div><div>Sure, here is me doing this by hand (from complexcreate.c):</div><div><br></div><div><div>  /* Build coordinates */</div>
<div>  ierr = DMComplexGetCoordinateSection(dm, &coordSection);CHKERRQ(ierr);</div><div>  ierr = PetscSectionSetChart(coordSection, numEdges, numEdges + numVertices);CHKERRQ(ierr);</div><div>  for (v = numEdges; v < numEdges+numVertices; ++v) {</div>
<div>    ierr = PetscSectionSetDof(coordSection, v, 2);CHKERRQ(ierr);</div><div>  }</div><div>  ierr = PetscSectionSetUp(coordSection);CHKERRQ(ierr);</div><div>  ierr = PetscSectionGetStorageSize(coordSection, &coordSize);CHKERRQ(ierr);</div>
<div>  ierr = VecCreate(((PetscObject) dm)->comm, &coordinates);CHKERRQ(ierr);</div><div>  ierr = VecSetSizes(coordinates, coordSize, PETSC_DETERMINE);CHKERRQ(ierr);</div><div>  ierr = VecSetFromOptions(coordinates);CHKERRQ(ierr);</div>
<div>  ierr = VecGetArray(coordinates, &coords);CHKERRQ(ierr);</div><div>  for (vy = 0; vy <= edges[1]; ++vy) {</div><div>    for (vx = 0; vx <= edges[0]; ++vx) {</div><div>      coords[(vy*(edges[0]+1)+vx)*2+0] = lower[0] + ((upper[0] - lower[0])/edges[0])*vx;</div>
<div>      coords[(vy*(edges[0]+1)+vx)*2+1] = lower[1] + ((upper[1] - lower[1])/edges[1])*vy;</div><div>    }</div><div>  }</div><div>  ierr = VecRestoreArray(coordinates, &coords);CHKERRQ(ierr);</div><div>  ierr = DMSetCoordinatesLocal(dm, coordinates);CHKERRQ(ierr);</div>
</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
What about having coordinates for the edges/faces/cells as well (to be<br>
interpreted as we want)?</blockquote><div><br></div><div>Yep, just give them a dof in the Section and set the values.</div><div><br></div><div>   Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb"><div class="h5">
On Wed, Sep 26, 2012 at 3:34 PM, Matthew Knepley <<a href="mailto:knepley@gmail.com">knepley@gmail.com</a>> wrote:<br>
> On Wed, Sep 26, 2012 at 5:24 PM, Chris Eldred <<a href="mailto:chris.eldred@gmail.com">chris.eldred@gmail.com</a>><br>
> wrote:<br>
>><br>
>> On the subject:<br>
>><br>
>> How do coordinates work for user-defined DMComplex objects? What<br>
>> determines the Coordinate section (and which points does it contain?)?<br>
>> How is the coordinate vector set?<br>
><br>
><br>
> I am just rewriting this. Now it will be<br>
><br>
>   DMGetCoordinateDM(DM, DM *)<br>
>   DMGetCoordinates(DM, Vec *)<br>
>   DMGetCoordinatesLocal(DM, Vec *)<br>
><br>
> and there is a convenience<br>
><br>
>   DMComplexGetCoordinateSection(DM, PetscSection *)<br>
><br>
> By default, I read in the vertex coordinates from the mesh generator.<br>
> However,<br>
> the idea is that you can interpret the coordinates however you want. We just<br>
> give you a DM and a vector. You can construct the section however you want,<br>
> although without vertex coordinates some default things will not work, like<br>
> VTK<br>
> output.<br>
><br>
>     Matt<br>
><br>
>><br>
>><br>
>> --<br>
>> Chris Eldred<br>
>> DOE Computational Science Graduate Fellow<br>
>> Graduate Student, Atmospheric Science, Colorado State University<br>
>> B.S. Applied Computational Physics, Carnegie Mellon University, 2009<br>
>> <a href="mailto:chris.eldred@gmail.com">chris.eldred@gmail.com</a><br>
><br>
><br>
><br>
><br>
> --<br>
> What most experimenters take for granted before they begin their experiments<br>
> is infinitely more interesting than any results to which their experiments<br>
> lead.<br>
> -- Norbert Wiener<br>
<br>
<br>
<br>
--<br>
Chris Eldred<br>
DOE Computational Science Graduate Fellow<br>
Graduate Student, Atmospheric Science, Colorado State University<br>
B.S. Applied Computational Physics, Carnegie Mellon University, 2009<br>
<a href="mailto:chris.eldred@gmail.com">chris.eldred@gmail.com</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>
-- Norbert Wiener<br>