← Back to team overview

dolfin team mailing list archive

Re: [Branch ~dolfin-core/dolfin/main] Rev 4990: Allow setting constant values for boundary conditions without using Constant.

 

On Mon, Aug 16, 2010 at 01:04:41PM +0200, Anders Logg wrote:
> On Mon, Aug 16, 2010 at 11:09:06AM +0100, Garth N. Wells wrote:
> > On Mon, 2010-08-16 at 10:03 +0000, noreply@xxxxxxxxxxxxx wrote:
> > > ------------------------------------------------------------
> > > revno: 4990
> > > committer: Anders Logg <logg@xxxxxxxxx>
> > > branch nick: dolfin-dev
> > > timestamp: Mon 2010-08-16 12:00:01 +0200
> > > message:
> > >   Allow setting constant values for boundary conditions without using Constant.
> > >   The following are equivalent:
> > >
> > >     c = Constant(foo)
> > >     bc = DirichletBC(V, c, boundary)
> > >
> > >     bc = DirichletBC(V, foo, boundary)
> > > modified:
> > >   demo/pde/poisson/python/demo.py
> > >   site-packages/dolfin/fem/bcs.py
> > >
> >
> > I've been meaning to do this for a while on the C++ side. Shouldn't it
> > be implemented in DirichetBC/.h/.cpp (some extra constructors)?
>
> The Python version of Constant (implemented in constant.py) does some
> tricks to convert input arguments to floats/arrays so I wanted to use
> that.
>
> But it would be nice to implement it in C++ too (separately), although
> I'm not sure what the best way is (if there's an alternative to
> implementing a bunch of extra constructors).
>

There are quite a few constructors in DirichletBC.h. I'm not very keen
on multiplying that by 2 or 3 as would be required to support at least
the following two constructors for Constant:

  Constant(double value);
  Constant(std::vector<double> values);

Is there some way to have C++ automatically convert a double to a
Constant? I thought the above constructor would take care of that.

--
Anders

Attachment: signature.asc
Description: Digital signature


References