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

서승진 (기계항공및원자력공학부) mistloin at unist.ac.kr
Thu Jan 18 05:10:18 CST 2018

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

[cid:009d718e-c50b-4bd9-8d2c-714321b9fc46]

[cid:40e3a7a8-4191-4693-bc97-84a550d5152f]

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.

[cid:c6eed790-070c-4e66-8dbb-8b461fb06f10]

[cid:37a6abda-13a5-45bd-b751-2d193f784071]

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, and second part is about setting of boundary condition.

However, due to second part, error occurs.

Is there any wrong argument? 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

I have studied the FEM before one month, but I am very confused by above four terms.

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

[cid:80900b60-6b68-4c72-8f3e-df0d475795d7]

I also have searched the tool which can express the visualized result and geometry.

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<mailto: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<mailto:bsmith at mcs.anl.gov>>
보낸 날짜: 2018년 1월 15일 월요일 오후 11:06:18
받는 사람: 서승진 (기계항공및원자력공학부)
참조: Smith, Barry F.; petsc-users at mcs.anl.gov<mailto: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<mailto: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<mailto:bsmith at mcs.anl.gov>>
> 보낸 날짜: 2017년 12월 21일 목요일 오후 3:46:42
> 받는 사람: 서승진 (기계항공및원자력공학부)
> 참조: petsc-users at mcs.anl.gov<mailto: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<mailto: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/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20180118/38080b84/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pastedImage.png
Type: image/png
Size: 109380 bytes
Desc: pastedImage.png
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20180118/38080b84/attachment-0006.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pastedImage.png
Type: image/png
Size: 134256 bytes
Desc: pastedImage.png
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20180118/38080b84/attachment-0007.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pastedImage.png
Type: image/png
Size: 74067 bytes
Desc: pastedImage.png
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20180118/38080b84/attachment-0008.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pastedImage.png
Type: image/png
Size: 43510 bytes
Desc: pastedImage.png
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20180118/38080b84/attachment-0009.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pastedImage.png
Type: image/png
Size: 24165 bytes
Desc: pastedImage.png
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20180118/38080b84/attachment-0010.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pastedImage.png
Type: image/png
Size: 8003 bytes
Desc: pastedImage.png
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20180118/38080b84/attachment-0011.png>
```