Relations
Richard Guenther
rguenth at tat.physik.uni-tuebingen.de
Tue Jun 15 13:23:10 UTC 2004
I'm a little bit confused about the ideas behind RelationListItem:
virtual void notifyPreRead()
{
if (Pooma::isRelationGroupActive(groups_m) && dirty_m)
{
apply();
clearDirty();
}
}
virtual void notifyPostWrite()
{
setDirty();
}
virtual void setDirty()
{
dirty_m = true;
}
virtual void clearDirty()
{
dirty_m = false;
}
why are _all_ these virtual? The only ever overloaded is setDirty (from
InfluenceRelation). Why do we have notifyPreRead()/notifyPostWrite() at
all? We use setDirty() in Field.h and applyRelations (which uses
notifyPreRead - ok).
I guess my idea would be to make setDirty/clearDirty non-virtual and
explicitly use notifyPreRead()/notifyPostWrite() where previously
setDirty/applyRelations was used.
The reason I'm looking at all this is because writing to a Field which
is the target of an Influence relation gets this relation dirtied and
re-applied before reading (Ok, maybe it's not nice what I'm doing, but
at the first look, it's quite confusing). So for me it would work
to override notifyPostWrite() in Relation1-n to do nothing.
So would be a patch like the one below ok? There would be the opportunity
to remove Field::setDirty() and Field::clearDirty(). I would leave
Field::applyRelations() alone, but maybe do not call notifyPreRead() from
it but some sort of run() directly.
Richard.
--
Richard Guenther <richard dot guenther at uni-tuebingen dot de>
WWW: http://www.tat.physik.uni-tuebingen.de/~rguenth/
===== Field.h 1.15 vs edited =====
--- 1.15/r2/src/Field/Field.h Thu May 27 10:56:35 2004
+++ edited/Field.h Tue Jun 15 14:56:08 2004
@@ -1606,6 +1606,22 @@
}
}
+ /// notify relations of upcoming read
+ void notifyPreRead() const
+ {
+ for (int m = 0; m < numMaterials(); ++m)
+ for (int c = 0; c < centering().size(); ++c)
+ fieldEngine_m.data(m, c).relations().notifyPreRead();
+ }
+
+ /// notify relations of past write
+ void notifyPostWrite() const
+ {
+ for (int m = 0; m < numMaterials(); ++m)
+ for (int c = 0; c < centering().size(); ++c)
+ fieldEngine_m.data(m, c).relations().notifyPostWrite();
+ }
+
/// dirty field, dirtying all relations
void setDirty() const
{
@@ -1630,6 +1646,20 @@
}
}
+ /// checks, if any of the fields relations is dirty
+ bool isDirty() const
+ {
+ for (int m = 0; m < numMaterials(); ++m)
+ {
+ for (int c = 0; c < centering().size(); ++ c)
+ {
+ if (fieldEngine_m.data(m, c).relations().dirty())
+ return true;
+ }
+ }
+ return false;
+ }
+
//@}
private:
@@ -1853,7 +1883,7 @@
// that it is going to be read and, therefore, needs to update itself.
//
// The second handles fields other than those with expression-engines by simply
-// calling applyRelations(). The third passes the tag to the leaves.
+// calling notifyPreRead(). The third passes the tag to the leaves.
//
// Fields with engines that store internal fields AND don't copy those
// fields' relations to its list must provide a specialization to get the
@@ -1874,7 +1904,7 @@
inline static
Type_t apply(const Subject_t &f, const PerformUpdateTag &)
{
- f.applyRelations();
+ f.notifyPreRead();
return 0;
}
};
@@ -2014,7 +2044,7 @@
const Field<Mesh, T, EngineTag> &l = lhs.subField(m, c);
if (AssignOpReadWriteTraits<Op>::readLHS)
- l.applyRelations();
+ l.notifyPreRead();
// Evaluate.
@@ -2023,7 +2053,7 @@
// Having done the evaluation, we need to notify the LHS
// that we've just written.
- l.setDirty();
+ l.notifyPostWrite();
}
}
@@ -2053,7 +2083,7 @@
forEach(r, PerformUpdateTag(), NullCombine());
if (AssignOpReadWriteTraits<Op>::readLHS)
- l.applyRelations();
+ l.notifyPreRead();
// Evaluate.
@@ -2062,7 +2092,7 @@
// Having done the evaluation, we need to notify the LHS
// that we've just written.
- l.setDirty();
+ l.notifyPostWrite();
}
}
@@ -2086,7 +2116,7 @@
const Field<Mesh, T, EngineTag> &l = lhs.subField(m, c);
if (AssignOpReadWriteTraits<Op>::readLHS)
- l.applyRelations();
+ l.notifyPreRead();
// Make an array out of the scalar.
@@ -2101,7 +2131,7 @@
// Having done the evaluation, we need to notify the LHS
// that we've just written.
- l.setDirty();
+ l.notifyPostWrite();
}
}
===== Relations/RelationList.h 1.3 vs edited =====
--- 1.3/r2/src/Field/Relations/RelationList.h Wed Dec 3 12:30:42 2003
+++ edited/Relations/RelationList.h Tue Jun 15 15:03:23 2004
@@ -242,7 +242,10 @@
//---------------------------------------------------------------------------
- // Set/clear the dirty flags for all of the relations.
+ //@name dirty flag handling, deprecated
+ //@{
+
+ /// Set the dirty flags for all relations.
void setDirty() const
{
@@ -250,12 +253,25 @@
list_m->elem(i)->setDirty();
}
+ /// Set the dirty flags for all relations.
+
void clearDirty() const
{
for (int i = 0; i < list_m->size(); ++i)
list_m->elem(i)->clearDirty();
}
+ /// Query if any of the relations is dirty.
+
+ bool dirty() const
+ {
+ for (int i = 0; i < list_m->size(); ++i)
+ if (list_m->elem(i)->dirty())
+ return true;
+ return false;
+ }
+
+ //@}
//---------------------------------------------------------------------------
// Give access to a specific relation.
===== Evaluator/MultiArgEvaluator.h 1.19 vs edited =====
--- 1.19/r2/src/Evaluator/MultiArgEvaluator.h Thu May 27 10:56:35 2004
+++ edited/Evaluator/MultiArgEvaluator.h Tue Jun 15 14:50:38 2004
@@ -104,7 +104,7 @@
template<class A>
inline void dirtyRelations(const A &a, const WrappedInt<true>&) const
{
- a.setDirty();
+ a.notifyPostWrite();
}
template<class A>
More information about the pooma-dev
mailing list