[petsc-users] I have a question for PETSc example

Matthew Knepley knepley at gmail.com
Thu Jan 18 22:37:38 CST 2018


On Thu, Jan 18, 2018 at 10:46 PM, 서승진 (기계항공및원자력공학부) <mistloin at unist.ac.kr>
wrote:

> Dear petsc-user.
>
>
> Thanks for your respond.
>
>
> *2) About application boundary condition*
> *2-1) About my geometry*
>
> The reason why I use DMPlexMarkBoundaryFaces() is to mark the boundary
> faces where dirichlet condition is applied.
>
> I accepted your advise, so there is no DMPlexMarkBoundaryFaces() in
> my code.
>
>
>
> I want to explain my problem with my geometry. I want to solve the heat
> transfer equation (only conduction with internal heat source Q) with four
> boundary condition.
>
>   Governing equation is
>
>   Left and Top : Dirichlet condition (T=T1, T=T2) (T1 < T, T2 < T)
>
>   Right and Bottom : Neumann condition (grad(T)=0 or -k*grad(T)=q)
>
> Heat is supplied from bottom boundary and generated in internal region,
> and it is transferred to left and top boundary.
>
> Internal heat source is function of temperature, so the problem is
> non-linear problem.
>

I recommend using a constant source to start, so you can use MMS and look
at the actual error. This is invaluable for debugging, and
you will see that all my examples do it.


> *2-2) About error message*
>
> The error message which I mentioned in previous mail is that
>

You are giving the name of a label that does not exist I think. You can
check what labels are defined (and how many points for each value)
using -dm_view.


>
> *2-3) About inhomogeneous neumann boundary condition *
>
>  You kindly answer my question; "If they are inhomogeneous, you must
> specify a part of the weak form, as is done in SNES ex12 and ex77."
>
>  Is that means I should specify terms "f0_bd_u" and "f1_bd_u" in weak
> form? (they are integrated along boundary line/surface in weak form)
>

Yes.


> *2-4) About dirichlet boundary condition *
>
>  Simplicial finite element examples (ex12, ex77, ex56) set the exact
> function ( = exact solution, for example, u=x^2+y^2 in ex12) as dirichlet
> condition.
>
>  Is the condition menas that we set the exact "u" values on the boundary
> (labeled as "marker")?
>

The Dirichlet conditions is always the exact value on the boundary. That is
what it means.

  Thanks,

     Matt


>  Thanks for reading my email.
>
>
> Best regard,
>
> Seungjin Seo
> ------------------------------
> *보낸 사람:* Matthew Knepley <knepley at gmail.com>
> *보낸 날짜:* 2018년 1월 19일 금요일 오전 1:09:02
> *받는 사람:* 서승진 (기계항공및원자력공학부)
> *참조:* Smith, Barry F.; petsc-users at mcs.anl.gov
> *제목:* Re: [petsc-users] I have a question for PETSc example
>
> On Thu, Jan 18, 2018 at 6:10 AM, 서승진 (기계항공및원자력공학부) <mistloin at unist.ac.kr>
> wrote:
>
> Dear petsc-user.
>
>
> Hi. I am trying several parts of example code, (SNES ex12.c : Poisson
> Problem in 2d and 3d with simplicial finite element)
>
>
> and I have several problems to understand.
>
>
> I appologize to sent a long and boring email to you...
>
>
> *1) About setting of geometry*
>
> I referred the "DMPlexCreateBoxMesh" function to make simplicial box mesh.
>
> I found that lower[] and upper[] are factors to set the size of the box
> mesh. Is it right?
>
> Actually, I want to make a rectangular geometry with size of 3m x 1m, and
> four boundary (two dirichlet and two neumann condition).
>
> If I wrong, please give me some tip to make a good geometry.
>
>
> Yes, you can use DMPlexCreateBoxMesh() to make that.
>
>
> *2) About application boundary condition*
>
> I reffered the example "SNES ex69.c" to set a label and condition for the
> four boundarys.
>
> First part of code is about label of boundary condition,
>
>
> This is wrong. You should not have DMPlexMarkBoundaryFaces() in there.
> What did you want it to do?
>
>
> and second part is about setting of boundary condition.
>
> However, due to second part, error occurs.
>
>
> Always, always, always send the full error message. Otherwise, I am just
> guessing.
>
>
> Is there any wrong argument?
>
>
> If they are homogeneous Neumann conditions, there is no need to mark them.
> If they are inhomogeneous, you
> must specify a part of the weak form, as is done in SNES ex12 and ex77.
>
> Second, for the Dirichlet conditions, are you sure you only want to
> constrain the components that I am in ex69?
> What would help is to fully specify your problem, so that we know what you
> want to do.
>
>
> Please give me some tip to applied four boundary conditions on the mesh.
>
>
> *3) About input parameters of DSSetJacobian()*
>
> In DSSetJacobian (prob, f, g, g0, g1, g2, g3), I have a problem to
> understand g0~g3
>
>  g0 : integrand for test function and basis function
>
>  g1 : integrand for test function gradient and basis function
>
>  g2 : integrand for test function and basis function gradient
>
>  g3 : integrand for test function gradient and basis function gradient
>
>
> I have studied the FEM before one month, but I am very confused by above
> four terms.
>
>
> There is a short explanation here:
>
>   http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/DT/
> PetscDSSetJacobian.html
>
> and here you can see the four terms which are being integrated to arrive
> at the element matrix:
>
>   http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/DT/
> PetscFEIntegrateJacobian.html
>
>
> I should study this in my self, but I need to some tip or internet address
> which include a helpful description about above terms.
>
>
> (I think this issue is not good at this email, but I have been really
> suffered by above term...)
>
>
>
> *4) About useful tool to visualize the result and geometry *
>
>
> I also have searched the tool which can express the visualized result and
> geometry.
>
>
> I use Paraview from KitWare, which is free. I output HDF5, using the
> generic PETSc Viewer options detailed in the manual,
>
>   -dm_view hdf5:lap.h5 -vec_view hdf5:lap.h5::append
>
> and then I automatically create an XDMF file lap.xmf, describing the HDF5,
> which can be read by Paraview,
>
>   $PETSC_DIR/bin/petsc_gen_xdmf.py lap.h5
>
>   Thanks,
>
>      Matt
>
>
> Could you give me a tip to select the visualizing tool for better analysis?
>
>
>
>
> Thanks you for reading my email.
>
>
> Best regards,
>
> Seungjin Seo
>
>
>
> ------------------------------
> *보낸 사람:* Matthew Knepley <knepley at gmail.com>
> *보낸 날짜:* 2018년 1월 16일 화요일 오후 8:48:16
> *받는 사람:* 서승진 (기계항공및원자력공학부)
> *참조:* Smith, Barry F.; petsc-users at mcs.anl.gov
> *제목:* Re: [petsc-users] I have a question for PETSc example
>
> On Mon, Jan 15, 2018 at 8:28 PM, 서승진 (기계항공및원자력공학부) <mistloin at unist.ac.kr>
> wrote:
>
> sorry, I mean that
>
> *My geometry is a rectangle*.
>
> That means, geometry is just rectangle box shape with four boundary.
>
>
> My question is that, how can I set the four boundary condition
> individually in example 12 of SNES?
>
>
> You put a different marker on each side. The easiest way to do it is to
> give the
>
>   -dm_plex_separate_marker
>
> option. This is done in SNES ex69.
>
>   Thanks,
>
>      Matt
>
>
> (I think that the boundary condition should be added in right side of the
> weak form, where load vector f and test function term is included. However,
> in example of petsc, boundary condition is applied as general form.)
>
>
> Seungjin Seo
> ------------------------------
> *보낸 사람:* Smith, Barry F. <bsmith at mcs.anl.gov>
> *보낸 날짜:* 2018년 1월 15일 월요일 오후 11:06:18
> *받는 사람:* 서승진 (기계항공및원자력공학부)
> *참조:* Smith, Barry F.; petsc-users at mcs.anl.gov
>
> *제목:* Re: [petsc-users] I have a question for PETSc example
>
>
>    The term "rectangular mesh" usually refers to a "structured grid mesh"
> so it is not clear if you truly need an unstructured grid. Take a look at
> src/snes/examples/tutorials/ex19.c
>
>   Barry
>
>
> > On Jan 15, 2018, at 1:03 AM, 서승진 (기계항공및원자력공학부) <mistloin at unist.ac.kr>
> wrote:
> >
> > Dear PETSc-user
> >
> > I am Seungjin Seo, researcher of Korean Advanced Institute of Science
> and Technology, South Korea.
> >
> > I am tring to understand the ex12.c in SNES examples, and I have a
> problem...
> > Could you give me some advise? Is there any good description or
> materials for PetscFE and DMPlex?
> >
> > I will make a code with unstructured grid with PetscFE and SNES. My
> geometry is a rectangle mesh (the size is not fixed so I think this is
> unstructured grid).
> > The equation is
> > I will set boundry conditions as follow;
> >   1. (Top-side boundary) Neumann boundary
> >   2. (Bottom-side boundary) Neumann boundary
> >   3. (Left-side boundary) Dirichlet boundary
> >   4. (Right-side boundary) Dirichlet boundary
> >
> > In example ex12.c in SNES, load vector f is defiend as f_0, and neumann
> boundary condition is defined as f_bd_0. f_1 means the test function
> gradient term. The example set general type of neumann boundary condition
> on f_bd_0, but I want to set each boundary condition individually. Could
> you give me some advise?
> >
> > Thansk for reading my email.
> >
> > Best regard,
> > Seungjin Seo
> >
> >
> >
> > 보낸 사람: Smith, Barry F. <bsmith at mcs.anl.gov>
> > 보낸 날짜: 2017년 12월 21일 목요일 오후 3:46:42
> > 받는 사람: 서승진 (기계항공및원자력공학부)
> > 참조: petsc-users at mcs.anl.gov
> > 제목: Re: [petsc-users] I have a question for PETSc example
> >
> >
> >   In deed you can, yes many PETSc examples only feature a single field
> for simplicity, but multiple fields are fine. You simple provide your
> FormFunction and FormJacobian to handle both degrees of freedom per
> cell/node at the same time. You use SNES or TS depending on if your problem
> is time dependent and then use -pc_type lu to start. Once you have the
> physics correct come back and ask us about optimizing the linear solver
> with preconditioners; but until you have the physics correct it is absurd
> to waste time worrying about making the linear solver efficient. What you
> want to do, many people do and is not a big deal.
> >
> >    Barry
> >
> >
> > > On Dec 21, 2017, at 12:27 AM, 서승진 (기계항공및원자력공학부) <mistloin at unist.ac.kr>
> wrote:
> > >
> > > Dear PETSc-user
> > >
> > >
> > > I am Seungjin Seo, researcher of Korean Advanced Institute of Science
> and Technology, South Korea.
> > >
> > >
> > >
> > > I am trying to solve thermal and fluid equations within a porous
> structure.
> > > The thermal equation includes a non-linear term of pressure and the
> fluid equation has a boundary condition using temperature gradient.
> > > Is there any way I can solve these two equations at the same time,
> instead of solving temperature first with previous pressure distribution
> and then pressure and update temperature?
> > > Many examples solve only one PDF instead of coupling several physics.
> > > Please recommend me which solver is appropriate for my case?
> > >
> > > Best regards,
> > > Seungjin Seo
>
>
>
>
> --
> 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
>
> https://www.cse.buffalo.edu/~knepley/ <http://www.caam.rice.edu/~mk51/>
>
>
>
>
> --
> 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
>
> https://www.cse.buffalo.edu/~knepley/ <http://www.caam.rice.edu/~mk51/>
>



-- 
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

https://www.cse.buffalo.edu/~knepley/ <http://www.caam.rice.edu/~mk51/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20180118/511d1cbc/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pastedImage.png
Type: image/png
Size: 43510 bytes
Desc: not available
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20180118/511d1cbc/attachment-0009.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pastedImage.png
Type: image/png
Size: 74067 bytes
Desc: not available
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20180118/511d1cbc/attachment-0010.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pastedImage.png
Type: image/png
Size: 8003 bytes
Desc: not available
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20180118/511d1cbc/attachment-0011.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pastedImage.png
Type: image/png
Size: 1135 bytes
Desc: not available
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20180118/511d1cbc/attachment-0012.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pastedImage.png
Type: image/png
Size: 76848 bytes
Desc: not available
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20180118/511d1cbc/attachment-0013.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pastedImage.png
Type: image/png
Size: 109380 bytes
Desc: not available
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20180118/511d1cbc/attachment-0014.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pastedImage.png
Type: image/png
Size: 134256 bytes
Desc: not available
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20180118/511d1cbc/attachment-0015.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pastedImage.png
Type: image/png
Size: 486428 bytes
Desc: not available
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20180118/511d1cbc/attachment-0016.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pastedImage.png
Type: image/png
Size: 24165 bytes
Desc: not available
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20180118/511d1cbc/attachment-0017.png>


More information about the petsc-users mailing list