Anders Logg wrote:
> On Mon, Mar 31, 2008 at 07:15:23PM +0200, Murtazo Nazarov wrote:
>   
>> Anders Logg wrote:
>>     
>>> On Mon, Mar 31, 2008 at 03:52:57PM +0200, Murtazo Nazarov wrote:
>>>   
>>>       
>>>> Hi,
>>>>
>>>> I want to apply a boundary condition to the vertices on a boundary. For 
>>>> that I define:
>>>>
>>>> // Sub domain for MyBC                                                     
>>>>                         
>>>> class MyBC_Boundary2D : public SubDomain
>>>> {
>>>> public:
>>>>   bool inside(const real* p, bool on_boundary) const
>>>>   {
>>>>     return  on_boundary && (p[0] < xmax - bmarg) && (p[0] > xmin + bmarg);
>>>>   }
>>>> };
>>>>
>>>> Then I initialize:
>>>> //-----------------------------------------------------------------------------
>>>>                       
>>>> void MyBC::init(SubDomain& sub_domain)
>>>> { ...
>>>>   mesh.init(0);
>>>>   sub_domains = new MeshFunction<uint>(mesh, 0);
>>>> ...}
>>>>     
>>>>         
>>> Do you remember to set everything to 1 (number of subdomains) here?
>>>
>>>   
>>>       
>> Yes I do:
>>
>>   // Mark everything as sub domain 
>> 1                                                                
>>   (*sub_domains) = 1;
>>
>>
>>   // Mark the sub domain as sub domain 
>> 0                                                            
>>   sub_domain.mark(*sub_domains, 0);
>>
>> /murtazo
>>     
>
> Then I have no idea. You just need to dig into the code and see what
> goes wrong.
>
>   
I think I found a mistake in Subdomain.mark(). The thing is bool 
on_boundary should be defined
 inside the loop for computing subdomain marker:

  // Always false when not marking 
facets                                                                          
          

  //bool on_boundary = 
false;                                                                          
                      


  // Compute sub domain 
markers                                                                         
                     

  for (MeshEntityIterator entity(mesh, dim); !entity.end(); ++entity)
  {
    bool on_boundary = false;
    ...
   }

Otherwise, if you want to apply a boundary condition on vertices, it 
becomes always
true after once meeting a vertex on the boundary.


It solved problem for me.

/murtazo
_______________________________________________
DOLFIN-dev mailing list
[email protected]
http://www.fenics.org/mailman/listinfo/dolfin-dev

Reply via email to