<p><b>cnewman@lanl.gov</b> 2010-08-06 15:51:07 -0600 (Fri, 06 Aug 2010)</p><p>More additions to implicit branch<br>
</p><hr noshade><pre><font color="gray">Modified: branches/implicit/Makefile
===================================================================
--- branches/implicit/Makefile        2010-08-06 19:14:48 UTC (rev 469)
+++ branches/implicit/Makefile        2010-08-06 21:51:07 UTC (rev 470)
@@ -159,6 +159,7 @@
 #########################
 ifdef TRILINOS_HOME
    include $(TRILINOS_HOME)/include/Makefile.export.Epetra
+   include $(TRILINOS_HOME)/include/Makefile.export.NOX
         MPI_HOME=/opt/OpenMPI/openmpi-1.2.8-gcc/ib
         MPIINC = -I$(MPI_HOME)/include
         MPILIB = -L$(MPI_HOME)/lib64 -lmpi_cxx
@@ -173,7 +174,7 @@
    ifdef TRILINOS_LIB_PATH
       LIBS += -L$(TRILINOS_LIB_PATH) -lzoltan
    else
-      LIBS += -L$(TRILINOS_HOME)/lib $(EPETRA_LIBRARIES) $(MPILIB) $(EPETRA_TPL_LIBRARIES) -lstdc++ 
+      LIBS += -L$(TRILINOS_HOME)/lib $(EPETRA_LIBRARIES) $(MPILIB) $(EPETRA_TPL_LIBRARIES) $(NOX_LIBRARIES) -lstdc++ 
    endif
 endif
 #########################

Modified: branches/implicit/src/core_sw/Makefile
===================================================================
--- branches/implicit/src/core_sw/Makefile        2010-08-06 19:14:48 UTC (rev 469)
+++ branches/implicit/src/core_sw/Makefile        2010-08-06 21:51:07 UTC (rev 470)
@@ -6,7 +6,7 @@
        module_time_integration_support.o \
        module_implicit_integration.o \
        module_time_integration.o \
-       mpas_interface.o nox_driver.o
+       mpas_interface.o nox_driver.o nox_interface.o
 
 all: core_sw
 
@@ -19,7 +19,7 @@
 
 module_implicit_integration.o:
 
-mpas_interface.o:  module_time_integration_support.o  module_implicit_integration.o module_test_cases.o module_time_integration.o nox_driver.o
+mpas_interface.o:  module_time_integration_support.o  module_implicit_integration.o module_test_cases.o module_time_integration.o nox_driver.o nox_interface.o
 
 clean:
         $(RM) *.o *.mod *.f90 libdycore.a

Modified: branches/implicit/src/core_sw/nox_driver.C
===================================================================
--- branches/implicit/src/core_sw/nox_driver.C        2010-08-06 19:14:48 UTC (rev 469)
+++ branches/implicit/src/core_sw/nox_driver.C        2010-08-06 21:51:07 UTC (rev 470)
@@ -1,6 +1,6 @@
-
 #include &quot;NOX.H&quot;
 #include &quot;NOX_Epetra.H&quot;
+#include &quot;Epetra_Vector.h&quot;
 
 #ifdef HAVE_MPI
 #include &quot;Epetra_MpiComm.h&quot;
@@ -31,6 +31,9 @@
 }
 
 static Teuchos::RCP&lt;Problem_Interface&gt; interface;
+static Teuchos::RCP&lt;NOX::Epetra::LinearSystem&gt; linsys;
+static Teuchos::RCP&lt;NOX::Solver::Generic&gt; solver;
+static Teuchos::RCP&lt;NOX::Epetra::Vector&gt; initialGuess;
 
 extern &quot;C&quot; {
 
@@ -120,8 +123,77 @@
   // Create the interface between the test problem and the nonlinear solver
   // This is created by the user using inheritance of the abstract base class:
   // NOX_Epetra_Interface
-  //interface = Teuchos::rcp(new Problem_Interface(*nelems, statevector, Comm,
-  //                                   blackbox_res, residualFunction));
+  interface = Teuchos::rcp(new Problem_Interface(*nelems, statevector, Comm,
+                                   blackbox_res, residualFunction));
+
+  Teuchos::RCP&lt;NOX::Epetra::Interface::Required&gt; iReq = interface;
+
+  // Create the Epetra_Vector for the  state vector
+  //Teuchos::RCP&lt;Epetra_Vector&gt; soln=Teuchos::rcp(new  Epetra_Vector(interface-&gt;getVector()));
+  Teuchos::RCP&lt;Epetra_Vector&gt; soln = interface-&gt;getVector();
+
+  // Create the nox vector
+  initialGuess = Teuchos::RCP&lt;NOX::Epetra::Vector&gt;(new NOX::Epetra::Vector(soln));
+                                                        
+  Teuchos::RCP&lt;NOX::Epetra::MatrixFree&gt; FD =
+    Teuchos::rcp(new NOX::Epetra::MatrixFree(nlPrintParams, interface, soln));
+
+  Teuchos::RCP&lt;NOX::Epetra::Interface::Jacobian&gt; iJac = FD;
+
+// note: it doesn't matter if this is null
+  Teuchos::RCP&lt;NOX::Epetra::Scaling&gt; scaling = interface-&gt;getScaling();
+// Create the Group
+  Teuchos::RCP&lt;NOX::Epetra::Group&gt; grp =
+    Teuchos::rcp(new NOX::Epetra::Group(nlPrintParams, iReq, *initialGuess, 
+                                        linsys)); 
+
+// Create the convergence tests
+  Teuchos::RCP&lt;NOX::StatusTest::NormF&gt; absresid = 
+    Teuchos::rcp(new NOX::StatusTest::NormF(1.0e-8));
+  Teuchos::RCP&lt;NOX::StatusTest::NormF&gt; relresid = 
+    Teuchos::rcp(new NOX::StatusTest::NormF(*grp.get(), 1.0e-4));
+  Teuchos::RCP&lt;NOX::StatusTest::NormUpdate&gt; update =
+    Teuchos::rcp(new NOX::StatusTest::NormUpdate(1.0e-5));
+  Teuchos::RCP&lt;NOX::StatusTest::NormWRMS&gt; wrms =
+    Teuchos::rcp(new NOX::StatusTest::NormWRMS(1.0e-2, 1.0e-8));
+  Teuchos::RCP&lt;NOX::StatusTest::Combo&gt; converged =
+    Teuchos::rcp(new NOX::StatusTest::Combo(NOX::StatusTest::Combo::AND));
+  converged-&gt;addStatusTest(absresid);
+  converged-&gt;addStatusTest(relresid);
+  converged-&gt;addStatusTest(wrms);
+  converged-&gt;addStatusTest(update);
+  Teuchos::RCP&lt;NOX::StatusTest::MaxIters&gt; maxiters = 
+    Teuchos::rcp(new NOX::StatusTest::MaxIters(200)); // cut this back for now
+//    Teuchos::rcp(new NOX::StatusTest::MaxIters(20));
+  Teuchos::RCP&lt;NOX::StatusTest::FiniteValue&gt; fv =
+    Teuchos::rcp(new NOX::StatusTest::FiniteValue);
+  Teuchos::RCP&lt;NOX::StatusTest::Combo&gt; combo = 
+    Teuchos::rcp(new NOX::StatusTest::Combo(NOX::StatusTest::Combo::OR));
+  combo-&gt;addStatusTest(fv);
+  combo-&gt;addStatusTest(converged);
+  combo-&gt;addStatusTest(maxiters);
+  Teuchos::RCP&lt;Teuchos::ParameterList&gt; nlParamsRCP = Teuchos::rcp(&amp;nlParams, false);
+  solver = NOX::Solver::buildSolver(grp, combo, nlParamsRCP);
+
 }
 
+void noxsolve(int* nelems, double* statevector,
+             void* blackbox_res, void* blackbox_prec)
+{
+    // reset solver with new initial Guess
+    Epetra_Vector&amp; initialGuessEV = initialGuess-&gt;getEpetraVector();
+    for (int i=0; i&lt;*nelems; i++) initialGuessEV[i] = statevector[i];
+    solver-&gt;reset(*initialGuess);
+    // reset interface with new blackbox
+    interface-&gt;resetBlackbox(blackbox_res, blackbox_prec);
+    NOX::StatusTest::StatusType status = solver-&gt;solve();
+
+    // copy out final solution
+    const Epetra_Vector&amp; finalSolution = (dynamic_cast&lt;const NOX::Epetra::Vector&amp;&gt;
+          (solver-&gt;getSolutionGroup().getX())).getEpetraVector();
+    for (int i=0; i&lt;*nelems; i++) statevector[i] = finalSolution[i];
+
 }
+
+
+}

Modified: branches/implicit/src/core_sw/nox_interface.C
===================================================================
--- branches/implicit/src/core_sw/nox_interface.C        2010-08-06 19:14:48 UTC (rev 469)
+++ branches/implicit/src/core_sw/nox_interface.C        2010-08-06 21:51:07 UTC (rev 470)
@@ -1,15 +1,24 @@
-#include nox_interface.h
+#include &quot;nox_interface.h&quot;
+//using Teuchos::RCP;
+//using Teuchos::rcp;
 
+Problem_Interface::Problem_Interface(int nelems, 
+                                     double* statevector,
+                                     const Epetra_Comm&amp; comm_,
+                                     void* blackbox_res, 
+                                     void (*residualFunction)(double *, double *, int, void *, double))
+ : N(nelems),
+   comm(comm_)
+{ 
+this-&gt;Create(statevector);
+}
 
-Problem_Interface::Problem_Interface(*nelems, statevector, Comm,
-                                       blackbox_res, residualFunction)
+Problem_Interface::~Problem_Interface()
 { }
-  ~Problem_Interface()
-{ }
 
   //! Compute and return F
   bool Problem_Interface::computeF(const Epetra_Vector&amp; x, Epetra_Vector&amp; FVec, 
-                FillType flag = Residual)
+                FillType flag)
 { }
 
   //! Compute an explicit Jacobian
@@ -22,6 +31,45 @@
   
   //! Computes a user supplied preconditioner based on input vector x.  Returns true if computation was successful.
   bool Problem_Interface::computePreconditioner(const Epetra_Vector&amp; x, Epetra_Operator&amp; M,
-                             Teuchos::ParameterList* precParams = 0)
+                             Teuchos::ParameterList* precParams)
 { }
 
+Teuchos::RCP&lt;Epetra_Vector&gt; Problem_Interface::getVector() const
+{ 
+  return solution;
+}
+
+Teuchos::RCP&lt;NOX::Epetra::Scaling&gt; Problem_Interface::getScaling() const
+  {
+  return scaling;
+  }
+
+void Problem_Interface::Create(double* statevector)
+  {
+  globalMap = Teuchos::rcp(new Epetra_Map(-1, N, indexBase_, comm));
+  solution = Teuchos::rcp(new Epetra_Vector(Copy, *globalMap, statevector));
+  
+//   left_scaling = rcp(new Epetra_Vector(*solution));
+//   right_scaling = rcp(new Epetra_Vector(*solution));
+  
+//   left_scaling-&gt;PutScalar(1.0);
+//   right_scaling-&gt;PutScalar(1.0);
+
+//   left_scaling-&gt;SetLabel(&quot;Left Scaling&quot;);
+//   right_scaling-&gt;SetLabel(&quot;Right Scaling&quot;);
+
+//   scaling = rcp(new NOX::Epetra::Scaling() );
+
+
+//   // note: the scaling will be recomputed, but Trilinos is
+//   // aware of that because it has a pointer:
+//   scaling-&gt;addUserScaling(NOX::Epetra::Scaling::Left,left_scaling);
+//   scaling-&gt;addUserScaling(NOX::Epetra::Scaling::Right,right_scaling);
+  
+  scaling = Teuchos::null; // we don't use scaling at the moment. If we need it, 
+                           // we probably have to put it in the IMPOP_BlockPreconditioner
+                           // as the outer iteration is Jacobian-free
+  
+//   label = &quot;IMPOP Interface (&quot;+prec_type+&quot; preconditioning)&quot;;
+//   DEBUG(&quot;Created Interface labelled '&quot;&lt;&lt;label&lt;&lt;&quot;'&quot;);
+  }

Modified: branches/implicit/src/core_sw/nox_interface.h
===================================================================
--- branches/implicit/src/core_sw/nox_interface.h        2010-08-06 19:14:48 UTC (rev 469)
+++ branches/implicit/src/core_sw/nox_interface.h        2010-08-06 21:51:07 UTC (rev 470)
@@ -8,20 +8,24 @@
 // ---------- Standard Includes ----------
 #include &lt;iostream&gt;
 #include &quot;Epetra_Vector.h&quot;
+#include &quot;Epetra_Map.h&quot;
 #include &quot;Epetra_Operator.h&quot;
 #include &quot;Epetra_RowMatrix.h&quot;
 #include &quot;NOX_Epetra_Interface_Required.H&quot; // base class
 #include &quot;NOX_Epetra_Interface_Jacobian.H&quot; // base class
 #include &quot;NOX_Epetra_Interface_Preconditioner.H&quot; // base class
+#include &quot;NOX_Epetra_Scaling.H&quot;
 
 class  Problem_Interface : public NOX::Epetra::Interface::Required,
                            public NOX::Epetra::Interface::Jacobian,
                            public NOX::Epetra::Interface::Preconditioner
 {
 public:
-  Problem_Interface(int nelems, double* statevector,
+  Problem_Interface(int nelems, 
+                    double* statevector,
                     const Epetra_Comm&amp; comm_,
-                    void* blackbox_res, void (*residualFunction)(double *, double *, int, void *, double));
+                    void* blackbox_res, 
+                    void (*residualFunction)(double *, double *, int, void *, double));
   ~Problem_Interface();
 
   //! Compute and return F
@@ -38,6 +42,27 @@
   bool computePreconditioner(const Epetra_Vector&amp; x, Epetra_Operator&amp; M,
                              Teuchos::ParameterList* precParams = 0);
 
+  Teuchos::RCP&lt;Epetra_Vector&gt; getVector() const;
+  Teuchos::RCP&lt;NOX::Epetra::Scaling&gt; getScaling() const;
+  void resetBlackbox(void* blackbox_res_,  void* blackbox_prec_) {
+    blackbox_res=blackbox_res_; blackbox_prec=blackbox_prec_; }
+
+private:
+  void* blackbox_res;
+  void* blackbox_prec;
+  Teuchos::RCP&lt;Epetra_Vector&gt; solution;
+  Teuchos::RCP&lt;NOX::Epetra::Scaling&gt; scaling;
+  //! number of elements on this process
+  int N;  
+  // global communicator
+  const Epetra_Comm&amp; comm;
+  //! index base of global map
+  static const int indexBase_=0;  
+  Teuchos::RCP&lt;Epetra_Map&gt; globalMap;
+  //! function called by all constructors (creates map etc.)
+  void Create(double* statevector);  
+
+
 };
 
 #endif

</font>
</pre>