> Shouldn't we go through all class members and try to copy as much as
> possible? The copy constructor of the mesh_fem class is a very
> fundamental point in getfem, we should make sure that the new
> constructor is as compatible as possible to the previous behavior.
> Kostas
> 
Dear All, 

I think what Kostas say is very important.

In the attachment I have a simple example I wrote to illustrate
the issue with context dependencies and copy constructor.
It creates a class Foo that inherits from  getfem::context_dependencies
and allows to see the pointers stored for context.

I have created Master, Slave and Master2 objects. Master and Master2 
depend on Slave. Master2 is copy of Master (default copy constructor).
As you can see the dependent object list for Slave has not been updated
to account for Master2.

On my machine the output looks like :

-------------------------------------------------8<---------
Dependent objects for Master 0xbfd0dbb0: 
     No depentend objects
Dependencies objects for Master 0xbfd0dbb0: 
   0xbfd0db88

 --------------

Dependent objects for Slave 0xbfd0db88: 
   0xbfd0dbb0
Dependencies objects for Slave 0xbfd0db88: 
     No dependencies objects

 --------------

Dependent objects for Master 0xbfd0db60: 
     No depentend objects
Dependencies objects for Master 0xbfd0db60: 
   0xbfd0db88

-------------------------------------------------8<---------

Of course name for Master2 is also wrong (the name for 0xbfd0db60
should be Master2).

This is the issue -- I will look how to fix it unless someone 
is quicker than me (I am going for holidays on Friday with no coputer :-). 
I have to understand what the method
void sup_dependency(const context_dependencies &cd) does --
it looks like it suppres the dependency, so the combination
of  add_dependency() and sup_dependency()  should do the job.
However I have to draw the dependency tree on paper to be sure
I understand whole issue.

This is all for now.

Regards,

Roman

-- 
Roman Putanowicz, PhD  < [email protected]  >
Institute for Computational Civil Engng (L-5)
Dept. of Civil Engng, Cracow Univ. of Technology
www.l5.pk.edu.pl, tel. +48 12 628 2569, fax 2034
#include <vector>
#include <getfem/getfem_context.h>
#include <iostream>
#include <string>

namespace getfem {
class Foo : public context_dependencies {
   public: 
   explicit Foo(const std::string &name) : myName(name) {}
   void print_dependent(void);
   void print_dependencies(void);
   void update_from_context(void) const;
   std::string myName;
};

void Foo::update_from_context(void) const {
  std::cout << "Do nothing on update from context" << "\n";
}

void Foo::print_dependent(void)  {
  std::cout << "Dependent objects for " << myName << " " << (void*) this <<  ": \n"; 
  if (dependent.size() < 1) {
    std::cout << "     No depentend objects\n";
  } else { 
    iterator_list it = dependent.begin(), ite = dependent.end();
    for (; it != ite; ++it) {
      std::cout <<  "   "  << (void*) *it <<"\n";
    }
  }
}

void Foo::print_dependencies(void)  {
  std::cout << "Dependencies objects for " << myName << " " << (void*) this <<  ": \n"; 
  if (dependencies.size() < 1) {
    std::cout << "     No dependencies objects\n";
  } else { 
    iterator_list it = dependencies.begin(), ite = dependencies.end();
    for (; it != ite; ++it) {
      std::cout <<  "   "  << (void*) *it << "\n";
    }
  }
}

} /* namespace getfem */
int main() {

   getfem::Foo master("Master");
   getfem::Foo slave("Slave");
   getfem::Foo master2("Master 2");

   master.add_dependency(slave);

   master.print_dependent();
   master.print_dependencies();

   std::cout << "\n\n --------------\n\n";
   slave.print_dependent();
   slave.print_dependencies();

   master2 = master; 

   std::cout << "\n\n --------------\n\n";
   master2.print_dependent();
   master2.print_dependencies();

}
_______________________________________________
Getfem-users mailing list
[email protected]
https://mail.gna.org/listinfo/getfem-users

Reply via email to