[Trilinos-Users] Deep copy bug?

Nico Schlömer nico.schloemer at ua.ac.be
Tue Mar 2 10:46:14 MST 2010


Dear all,

we've spent the afternoon tracking down an unexpected behavior in LOCA's
turning point continuation (in the latest master Git). Eventually it came
down line 122 in the file
packages/nox/src-loca/src/LOCA_TurningPoint_MooreSpence_ExtendedGroup.C:

[...]
*(xMultiVec.getColumn(0)->getNullVec()) = *nullVecPtr;
[...]

Presumably, this wants to do a deep copy of the contents of nullVecPtr
over to a LOCA structure. This does not seem to work.

We constructed a minimal example that reproduces the problem; see
attachment.

The deep copy works fine for int's, but not for NOX::Abstract::Vector's.

Any hints on how to solve this?

Daniele & Nico
-------------- next part --------------
TRILINOS_ROOT=/opt/trilinos/dev/gcc/4.3.4/
include ${TRILINOS_ROOT}/include/Makefile.client.NOX

EXE=teuchosTest.exe

GFORTRAN_LIB=/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.4/libgfortran.a

default: ${EXE}

%.exe : %.o $(EXTRA_OBJS)
	$(CXX) -o $@ $(LDFLAGS) $(CXXFLAGS) $< $(EXTRA_OBJS) -L$(LIB_PATH) $(LIBS) $(GFORTRAN_LIB)

clean:
	@rm -f *~ ${EXE}
-------------- next part --------------
#include <NOX_Epetra_Vector.H>

#include <Epetra_Vector.h>
#include <Epetra_Map.h>

#ifdef HAVE_MPI
#include <Epetra_MpiComm.h>
#else
#include <Epetra_SerialComm.h>
#endif

// ============================================================================
int
main()
{
    // Initialize MPI
#ifdef HAVE_MPI
    MPI_Init ( &argc,&argv );
#endif

    // create Epetra communicator
#ifdef HAVE_MPI
    Teuchos::RCP<Epetra_MpiComm> eComm =
        Teuchos::rcp<Epetra_MpiComm> ( new Epetra_MpiComm ( MPI_COMM_WORLD ) );
#else
    Teuchos::RCP<Epetra_SerialComm> eComm =
        Teuchos::rcp<Epetra_SerialComm> ( new Epetra_SerialComm() );
#endif
  
  int N = 5;
  Teuchos::RCP<Epetra_Map> map = Teuchos::rcp( new Epetra_Map( N, 0, *eComm ) );

  // instatiate and randomize xx
  Teuchos::RCP<Epetra_Vector> x =
        Teuchos::rcp( new Epetra_Vector(*map) );        
  Teuchos::RCP<NOX::Abstract::Vector> xx =
        Teuchos::rcp ( new NOX::Epetra::Vector ( *x ) );
  xx->random();
  xx->print(std::cout);
  
  // instatiate yy and copy contents over from xx
  Teuchos::RCP<Epetra_Vector> y =
        Teuchos::rcp( new Epetra_Vector(*map) );        
  Teuchos::RCP<NOX::Abstract::Vector> yy =
        Teuchos::rcp ( new NOX::Epetra::Vector ( *y ) );
  *y = *x;

  yy->print(std::cout);

  return 0;
}
// ============================================================================


More information about the Trilinos-Users mailing list