From: David K. <dkn...@se...> - 2013-01-26 17:43:12
|
To create the lift function, probably the simplest thing to do is solve a Laplace equation (\Laplacian u = 0) with the Dirichlet boundary conditions that you want, and then use the solution as your u0. This process is called "elliptic lifting" since the Laplace equation is an elliptic PDE. Then to assemble a(u0,v), you need to do something like what you wrote. But the code can be simplified a bit; you don't need to compute Ke and then multiply. You can just get the gradient of u0 directly (by multiplying the coefficients of u0 with c.interior_gradient) and then integrate. David On 01/26/2013 06:14 AM, Kyunghoon Lee wrote: > Thanks for the reply. Now I'd appreciate if you'd help me with the > implementation of a(u0,v). I was thinking of computing Ke*u0 where Ke is > the stiffness matrix and u0 is the lift function as below: > > //inhomogeneous Dirichlet BC > struct IDBCAssembly : ElemAssembly { > > short unsigned int sbd_id; > IDBCAssembly(short unsigned int sbd_id_in) : sbd_id(sbd_id_in) {} > > virtual void interior_assembly(FEMContext &c) { > > const unsigned int u_var = 0; > const std::vector<Real> &JxW = > c.element_fe_var[u_var]->get_JxW(); > const std::vector<std::vector<RealGradient> >& dphi = > c.element_fe_var[u_var]->get_dphi(); > > const unsigned int n_u_dofs = c.dof_indices_var[u_var].size(); > unsigned int n_qpoints = c.element_qrule->n_points(); > > // stiffness matrix Ke > std::vector<std::vector<Number> > Ke(n_u_dofs, > std::vector<Number>(n_u_dofs)); > for (unsigned int qp=0; qp != n_qpoints; qp++) > for (unsigned int i=0; i != n_u_dofs; i++) > for (unsigned int j=0; j != n_u_dofs; j++) > Ke[i][j] += JxW[qp] * dphi[j][qp] * dphi[i][qp]; > > // lift function u0 > std::vector<Number> u0(n_u_dofs, 0.0); > > // multiply stiffness matrix by lift function > for (unsigned int qp=0; qp != n_qpoints; qp++) > for (unsigned int i=0; i != n_u_dofs; i++) > for (unsigned int j=0; j != n_u_dofs; j++) > c.elem_residual(i) += Ke[i][j] * u0[j]; > } // end of interior_assembly > }; > > However, I'm not sure of how to create the lift function u0 such that it > has values for given boundary ID and zeros for elsewhere. I think I need > to the following: > > iterate nodes > if node belongs to the given boundary ID, set u0(i) = u0_given; otherwise > u(i) = 0.0 > > but I'm not sure of how to check whether a node is associated with boundary > ID. Can you help me with this problem, plz? (or are there examples related > to this issue?) > > Best, > K. Lee. > > > On Fri, Jan 25, 2013 at 12:38 PM, David Knezevic <dkn...@se... >> wrote: >> Yep, that's right, use the RB method to solve for u'. >> >> Note that you put a(u0,v) on the right-hand side, since u0 is known >> (it's the "lifting function"). >> >> David >> >> >> >> On 01/24/2013 11:34 PM, Kyunghoon Lee wrote: >>> Thanks for clearing it up. Then I guess we just solve for u' >>> >>> a(u',v) + a(u0,v) = f(v) >>> >>> and attach assemblies a(u',v), a(u0,v), and f(v) as usual, then restore u >>> by u = u' + u0. >>> >>> K. Lee. >>> >>> On Fri, Jan 25, 2013 at 12:17 PM, David Knezevic < >> dkn...@se... >>>> wrote: >>>> Hi K, >>>> >>>> heterogeneously_constrain_element_matrix_and_vector is not relevant to >>>> Reduced Basis stuff. For Reduced Basis formulations, you have to >>>> transform the problem using a lifting function so that it has zero >>>> Dirichlet BC's --- this is essential since you want your Reduced Basis >>>> space to be a vector space, i.e. it must contain 0 (which would be not >>>> be the case with non-zero Dirichlet BCs). This lifting function approach >>>> is what you described in your email already, so that's fine. >>>> >>>> Once you've transformed your problem using a lifting function, then you >>>> just proceed as normal, e.g. as in reduced_basis_ex1. The only trick is >>>> you have to add your lifting function back on at the end to recover u >>>> from u'. >>>> >>>> David >>>> >>>> >>>> >>>> On 01/24/2013 11:10 PM, Kyunghoon Lee wrote: >>>>> Hi all, >>>>> >>>>> In my previous email regarding inhomogeneous Dirichlet boundary >>>> conditions, >>>>> David suggested using >> heterogenously_constrain_element_matrix_and_vector >>>> in >>>>> introduction_ex4, but I'm not sure of how to deal with inhomogeneous >>>>> Dirichlet BCs in connection with reduced basis models. Suppose we >> have a >>>>> simple steady state heat conduction model whose BCs are u = T on \Gamma >>>> and >>>>> u = 0 on the rest surfaces. After variable change, we solve >>>>> >>>>> a(u',v) = f(v) - a(u0,v) >>>>> >>>>> where 1) u' = u - T on \Gamma and u' = u on the rest surfaces; and 2) >> u0 >>>> = >>>>> T on \Gamma and u0 = zero on the rest surfaces. I thought we build the >>>> LHS >>>>> then call attach_F_assembly to attach it, but in that case, I'm not >> sure >>>>> how heterogenously_constrain_element_matrix_and_vector can be used. Or >>>>> should we attach a(u',v) and f(v) as usual then call >>>>> heterogenously_constrain_element_matrix_and_vector to impose - a(u0,v) >> on >>>>> the LHS? I'd appreciate if someone can briefly describe how the >> function >>>>> work. >>>>> >>>>> Regards, >>>>> K. Lee. >>>>> >> ------------------------------------------------------------------------------ >>>>> Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS, >>>>> MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current >>>>> with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft >>>>> MVPs and experts. ON SALE this month only -- learn more at: >>>>> http://p.sf.net/sfu/learnnow-d2d >>>>> _______________________________________________ >>>>> Libmesh-users mailing list >>>>> Lib...@li... >>>>> https://lists.sourceforge.net/lists/listinfo/libmesh-users >>>> >>>> >> ------------------------------------------------------------------------------ >>>> Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS, >>>> MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current >>>> with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft >>>> MVPs and experts. ON SALE this month only -- learn more at: >>>> http://p.sf.net/sfu/learnnow-d2d >>>> _______________________________________________ >>>> Libmesh-users mailing list >>>> Lib...@li... >>>> https://lists.sourceforge.net/lists/listinfo/libmesh-users >>>> >> ------------------------------------------------------------------------------ >>> Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS, >>> MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current >>> with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft >>> MVPs and experts. ON SALE this month only -- learn more at: >>> http://p.sf.net/sfu/learnnow-d2d >>> _______________________________________________ >>> Libmesh-users mailing list >>> Lib...@li... >>> https://lists.sourceforge.net/lists/listinfo/libmesh-users >> >> >> ------------------------------------------------------------------------------ >> Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS, >> MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current >> with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft >> MVPs and experts. ON SALE this month only -- learn more at: >> http://p.sf.net/sfu/learnnow-d2d >> _______________________________________________ >> Libmesh-users mailing list >> Lib...@li... >> https://lists.sourceforge.net/lists/listinfo/libmesh-users >> > ------------------------------------------------------------------------------ > Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS, > MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current > with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft > MVPs and experts. ON SALE this month only -- learn more at: > http://p.sf.net/sfu/learnnow-d2d > _______________________________________________ > Libmesh-users mailing list > Lib...@li... > https://lists.sourceforge.net/lists/listinfo/libmesh-users |