dolfin team mailing list archive
-
dolfin team
-
Mailing list archive
-
Message #17164
Re: [Question #96848]: Binding an Object to Each Node
On Sun, Jan 10, 2010 at 07:02:22AM -0000, Ted Kord wrote:
> New question #96848 on DOLFIN:
> https://answers.launchpad.net/dolfin/+question/96848
>
> Hello
>
> Is there away to :
>
> 1. create and bind an object to each node in space.
>
> 2. have the object automatically update its state at every time step.
>
> My original approach was to create a pointer to the object in a subclass of expression ...... but the solution turns out to be the same the same at each time step. So, I know I'm definitely doing something wrong.
>
> Thanks in advance
>
> Ted
When you create a subclass of Expression, you can do whatever you like
as part of that class, for example by putting a vector of objects as a
member variable of your class.
But remember that for a time-dependent problem, you must yourself
update the value of t between time steps. Here's a sketch:
class MyExpression : public Expression
{
public:
MyExpression(const Mesh& mesh)
{
for (int i = 0; i < mesh.num_vertices(); ++i)
{
objects.push_back(...);
}
}
void eval(...)
{
...
}
void update(double t)
{
this->t = t;
}
private:
double t;
std::vector<Class> objects;
};
Then do something like this in your code:
MyExpression w(mesh);
while (t < T)
{
w.update(t);
solve
t += dt;
}
--
Anders
Attachment:
signature.asc
Description: Digital signature
Follow ups
References