The code for the definition of the region of interest below worked with
the adaptive algorithm. The integral is taken over a region surrounding
the point where the solution is evaluated.

How can the cell closest to (vbar, 0) be picked?

--Wilhelm

#######################################################
#code for using a cell integral over a certain region of interest to
define a goal function
#######################################################

    class region_of_interest(SubDomain):

        def inside(self, x, on_boundary):

        return (between(x[0], (vbar-0.5, vbar+0.5)) and between(x[1], (-0.5, 
0.5)))

    # Initialize sub-domain instances

    ROI = region_of_interest()

    cell_domains = CellFunction("size_t", mesh)

    cell_domains.set_all(0)

    ROI.mark(cell_domains, 1)

    dx_roi = Measure('dx')[cell_domains]

    #check whether ROI is empty or not

    if not ROI:

        print "problem, region of interest empty"

        exit()

    # Plot cell_domains

    #plot(cell_domains, interactive=True)

    M = u * dx_roi(1)


On 23/02/15 10:19, Martin Sandve Alnæs wrote:
> I would suggest using a cell integral and just marking a single cell
> containing your point.
>
> Martin
>
> On 23 February 2015 at 11:09, Wilhelm Braun <[email protected]
> <mailto:[email protected]>> wrote:
>
>     I just checked this, and I got
>
>     AssertionError
>
>
>     which means that the domain is indeed empty.
>
>     Is there a way to fix this by redefining the domain or by simply
>     refining the mesh at the point of interest before the start of the
>     computation?
>
>     --Wilhelm
>
>     On 21/02/15 18:46, Jan Blechta wrote:
>     > On Fri, 20 Feb 2015 17:22:36 +0000
>     > Wilhelm Braun <[email protected]
>     <mailto:[email protected]>> wrote:
>     >
>     >> I tried to implement the goal function using the point integral as
>     >> outlined in the point integral demo in DOLFIN.
>     >>
>     >> However, the point integral evaluated to zero, and hence, the
>     adaptive
>     >> algorithm stopped after one iteration, but did not throw an error.
>     >>
>     >> Please find the code for the definition of the goal function M
>     below.
>     >>
>     >> --Wilhelm
>     >>
>     >>
>     
> ----------------------------------------------------------------------------------------------------
>     >> code for goal function M
>     >>
>     
> ----------------------------------------------------------------------------------------------------
>     >>
>     >>
>     >>    def center_func(x):
>     >>             return (vbar-0.05 <= x[0] and x[0] <= vbar + 0.05 and
>     >> near(x[1], 0.0)) or -0.05 <= x[1] and x[1] <= 0.05 and near(x[0],
>     >> vbar)
>     >>
>     >>     # Define domain for point integral
>     >>     center_domain = VertexFunction("size_t", mesh, 0)
>     >>     center = AutoSubDomain(center_func)
>     >>     center.mark(center_domain, 1)
>     >>     dPP = dP[center_domain]
>     > Have you tested that center_domain is non-trivial? For example
>     >
>     > assert center_domain.array().max() > 0
>     >
>     > Jan
>     >
>     >>     M = u* dPP(1)
>     >>
>     >>
>     >>
>     
> ----------------------------------------------------------------------------------------------------
>     >>
>     
> ----------------------------------------------------------------------------------------------------
>     >>
>     >>
>     >>
>     >> On 20/02/15 11:23, Anders Logg wrote:
>     >>> I suggest looking at the point integral demo in DOLFIN:
>     >>>
>     >>> demo/undocumented/point-integral/python/demo_point-integral.py
>     >>>
>     >>> Then use the point integral to define you goal functional.
>     Warning:
>     >>> I haven't tested this myself and don't know if it will break the
>     >>> adaptive algorithm somehow. It would be interesting to get
>     feedback
>     >>> on whether it works (without any promise that I will fix it if it
>     >>> does not... ;-)
>     >>>
>     >>> --
>     >>> Anders
>     >>>
>     >>>
>     >>> Fri Feb 20 2015 at 11:47:10 AM skrev Wilhelm Braun
>     >>> <[email protected] <mailto:[email protected]>
>     <mailto:[email protected] <mailto:[email protected]>>>:
>     >>>
>     >>>     Dear all,
>     >>>
>     >>>     I have posted a question in the FEniCS QA forum, and it was
>     >>>     recommended that I bring up the issue on this mailing list.
>     >>>
>     >>>     Please have a look here for my question.
>     >>>
>     >>>   
>      
> http://fenicsproject.org/qa/6555/automated-oriented-adaptivity-point-computational-domain
>     >>>
>     >>>     Thank you very much!
>     >>>
>     >>>     Wilhelm Braun
>     >>>
>     >>>
>     >>>
>     >>>     This message and any attachment are intended solely for the
>     >>> addressee and may contain confidential information. If you have
>     >>> received this message in error, please send it back to me, and
>     >>> immediately delete it.
>     >>>
>     >>>     Please do not use, copy or disclose the information contained
>     >>> in this message or in any attachment.  Any views or opinions
>     >>> expressed by the author of this email do not necessarily reflect
>     >>> the views of the University of Nottingham.
>     >>>
>     >>>     This message has been checked for viruses but the contents
>     of an
>     >>>     attachment may still contain software viruses which could
>     >>> damage your computer system, you are advised to perform your own
>     >>> checks. Email communications with the University of Nottingham may
>     >>> be monitored as permitted by UK legislation.
>     >>>
>     >>
>     >>
>     >>
>     >>
>     >> This message and any attachment are intended solely for the
>     addressee
>     >> and may contain confidential information. If you have received this
>     >> message in error, please send it back to me, and immediately delete
>     >> it.
>     >>
>     >> Please do not use, copy or disclose the information contained
>     in this
>     >> message or in any attachment.  Any views or opinions expressed
>     by the
>     >> author of this email do not necessarily reflect the views of the
>     >> University of Nottingham.
>     >>
>     >> This message has been checked for viruses but the contents of an
>     >> attachment may still contain software viruses which could
>     damage your
>     >> computer system, you are advised to perform your own checks. Email
>     >> communications with the University of Nottingham may be
>     monitored as
>     >> permitted by UK legislation.
>     >>
>
>
>
>
>
>     This message and any attachment are intended solely for the addressee
>     and may contain confidential information. If you have received this
>     message in error, please send it back to me, and immediately
>     delete it.
>
>     Please do not use, copy or disclose the information contained in this
>     message or in any attachment.  Any views or opinions expressed by the
>     author of this email do not necessarily reflect the views of the
>     University of Nottingham.
>
>     This message has been checked for viruses but the contents of an
>     attachment may still contain software viruses which could damage your
>     computer system, you are advised to perform your own checks. Email
>     communications with the University of Nottingham may be monitored as
>     permitted by UK legislation.
>
>     _______________________________________________
>     fenics mailing list
>     [email protected] <mailto:[email protected]>
>     http://fenicsproject.org/mailman/listinfo/fenics
>
>





This message and any attachment are intended solely for the addressee
and may contain confidential information. If you have received this
message in error, please send it back to me, and immediately delete it. 

Please do not use, copy or disclose the information contained in this
message or in any attachment.  Any views or opinions expressed by the
author of this email do not necessarily reflect the views of the
University of Nottingham.

This message has been checked for viruses but the contents of an
attachment may still contain software viruses which could damage your
computer system, you are advised to perform your own checks. Email
communications with the University of Nottingham may be monitored as
permitted by UK legislation.

_______________________________________________
fenics mailing list
[email protected]
http://fenicsproject.org/mailman/listinfo/fenics

Reply via email to