## Re: [Libmesh-users] Nuemann boundary condition

 Re: [Libmesh-users] Nuemann boundary condition From: John Peterson - 2004-05-04 18:37:56 ```Shaoying Lu writes: > Thanks for the timely reply of John and Steffen. Your advices are really > helpful for me to understand the process of defining Nuemann and mixed BC. > > In my problem the BC's need to be defined at some given segment of the > boundary. Here is a follow-up question based on John's answer: > > It seems that the boudary type s decided by a user supplied function, > > user->is_neumann_boudnary() > > How would one define 'user' or 'user->is_neumann_boundary'? The "user" is a concept that we used in one of our application codes. Basically, the user must have some a-priori knowledge of the problem's boundary conditions to complete the is_neumann_boundary() function. A simple (1D) example is: bool is_neumann_boundary(double x) { if ( fabs(x - 1.) < 1.e-6) return true; else return false; } In this case, the boundary x=1 is a Neumann boundary, so we take the x location of the current element's node to determine if it is on the flux boundary. A more generic function will use boundary IDs. For example, let's say that boundary id 5 is a Neumann boundary for the temperature (T) variable. Then your function would look like: inline bool is_neumann_boundary(const unsigned short int id, const std::string& , const std::string& var_name) { if ((var_name == "T") && (id == 5)) return true; return false; } The boundary_id's for elements are typically specified by an external mesh generator. Or they can be set manually. Here's the function to obtain a boundary_id for Element side s. const unsigned int boundary_id = mesh.boundary_info.boundary_id (elem, s); Good luck, John ```

 [Libmesh-users] Nuemann boundary condition From: Shaoying Lu - 2004-05-03 22:49:35 ```Hello, I have the following question. All the examples seem to be using Dirichlet boundary contiion. Is there an example for the Nuemann boudnary condition? Or is there some files that would be really helpful for me to implement a Nuemann BC on the basis of example 4 ( the 3-d poisson problem)? Thank you very much for your help! Kathy ```
 AW: [Libmesh-users] Nuemann boundary condition From: Steffen Petersen - 2004-05-04 06:56:03 ```> Hello, > > I have the following question. All the examples seem to be > using Dirichlet > boundary contiion. Is there an example for the Nuemann > boudnary condition? Or is there some files that would be > really helpful for me to implement a > Nuemann BC on the basis of example 4 ( the 3-d poisson problem)? > > Thank you very much for your help! > > Kathy > > Yes, there is an example with Neumann BCs. Have a look at example 7. There, the Helmholtz equation is solved on a [-1,1]x[-1,1] mesh. In this example Neumann conditions with vn_value=1 (and also Robin/mixed conditions with an_value=1) are applied at all parts of the boundary. Steffen ```
 [Libmesh-users] Nuemann boundary condition From: John Peterson - 2004-05-04 01:24:30 ```Hi, The general technique is to build a finite element on the "face" or "edge" which is on the boundary and perform the integral (with a loop over gauss points, i, and j on the face) which appears in your variational statement. Here is a code fragment // Handle boundary conditions for (unsigned int s=0; sn_sides(); s++) if (elem->neighbor(s) == NULL) // on the boundary { const unsigned int boundary_id = mesh.boundary_info.boundary_id (elem, s); AutoPtr fe_face (FEBase::build(dim, flow_dof_map.variable_type (u_var))); QGauss qface (dim-1, Control::quadrature_order()); fe_face->attach_quadrature_rule (&qface); fe_face->reinit (elem, s); const std::vector >& phi_face = fe_face->get_phi(); const std::vector >& dphi_face = fe_face->get_dphi(); const std::vector& JxW_face = fe_face->get_JxW(); const std::vector& qface_point = fe_face->get_xyz(); const std::vector& normals = fe_face->get_normals(); // ... // T Flux boundary values else if (user->is_neumann_boundary(boundary_id, ((coupled) ? "rbm" : "thermal"), "T")) { for (unsigned int qp=0; qpneumann_boundary_value(qface_point[qp], normals[qp], time, ((coupled) ? "rbm" : "thermal"), "T", boundary_id); // Compute the integration on the face for (unsigned int i=0; i
 Re: [Libmesh-users] Nuemann boundary condition From: Shaoying Lu - 2004-05-04 17:01:37 ```Thanks for the timely reply of John and Steffen. Your advices are really helpful for me to understand the process of defining Nuemann and mixed BC. In my problem the BC's need to be defined at some given segment of the boundary. Here is a follow-up question based on John's answer: It seems that the boudary type s decided by a user supplied function, user->is_neumann_boudnary() How would one define 'user' or 'user->is_neumann_boundary'? Any comments will be very welcom! Kathy ```
 Re: [Libmesh-users] Nuemann boundary condition From: John Peterson - 2004-05-04 18:37:56 ```Shaoying Lu writes: > Thanks for the timely reply of John and Steffen. Your advices are really > helpful for me to understand the process of defining Nuemann and mixed BC. > > In my problem the BC's need to be defined at some given segment of the > boundary. Here is a follow-up question based on John's answer: > > It seems that the boudary type s decided by a user supplied function, > > user->is_neumann_boudnary() > > How would one define 'user' or 'user->is_neumann_boundary'? The "user" is a concept that we used in one of our application codes. Basically, the user must have some a-priori knowledge of the problem's boundary conditions to complete the is_neumann_boundary() function. A simple (1D) example is: bool is_neumann_boundary(double x) { if ( fabs(x - 1.) < 1.e-6) return true; else return false; } In this case, the boundary x=1 is a Neumann boundary, so we take the x location of the current element's node to determine if it is on the flux boundary. A more generic function will use boundary IDs. For example, let's say that boundary id 5 is a Neumann boundary for the temperature (T) variable. Then your function would look like: inline bool is_neumann_boundary(const unsigned short int id, const std::string& , const std::string& var_name) { if ((var_name == "T") && (id == 5)) return true; return false; } The boundary_id's for elements are typically specified by an external mesh generator. Or they can be set manually. Here's the function to obtain a boundary_id for Element side s. const unsigned int boundary_id = mesh.boundary_info.boundary_id (elem, s); Good luck, John ```