{ "cells": [ { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true, "slideshow": { "slide_type": "slide" } }, "source": [ "# MueLu - Hierarchy" ] }, { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "## Multigrid setup" ] }, { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "### General preparations" ] }, { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "Declare location of include headers " ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [ { "data": { "text/plain": [] }, "execution_count": 1, "metadata": {}, "output_type": "execute_result" } ], "source": [ ".I /opt/install/do-conf-ep-serial/include/" ] }, { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ " Load Trilinos libraries" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [ { "data": { "text/plain": [] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ ".L libepetra" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [ { "data": { "text/plain": [] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ ".L libxpetra" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [ { "data": { "text/plain": [] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ ".L libmuelu" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [ { "data": { "text/plain": [] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ ".L libteuchoscore" ] }, { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "Include some standard header files to create a communicator and an ```Xpetra::Map```" ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [ { "data": { "text/plain": [] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "#include \"Kokkos_DefaultNode.hpp\"\n", "#include \"Epetra_SerialComm.h\"\n", "#include \"Epetra_Vector.h\"\n", "#include \"Epetra_CrsMatrix.h\"\n", "#include \"Teuchos_RCP.hpp\"\n", "#include \"Teuchos_DefaultSerialComm.hpp\"\n", "#include \"Xpetra_MapFactory.hpp\"\n", "#include \"Xpetra_Map.hpp\"\n", "#include \"Xpetra_EpetraCrsMatrix.hpp\"" ] }, { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "Again, we use standard template parameters:" ] }, { "cell_type": "code", "execution_count": 7, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [ { "data": { "text/plain": [] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "typedef double Scalar;\n", "typedef int LocalOrdinal;\n", "typedef int GlobalOrdinal;\n", "typedef Kokkos::Compat::KokkosSerialWrapperNode EpetraNode;\n", "typedef EpetraNode Node;\n", "typedef Scalar SC;\n", "typedef LocalOrdinal LO;\n", "typedef GlobalOrdinal GO;\n", "typedef Node NO;" ] }, { "cell_type": "code", "execution_count": 8, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [ { "data": { "text/plain": [] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "#include \"Xpetra_CrsMatrixWrap.hpp\"\n", "#include \"Xpetra_CrsMatrix.hpp\"\n", "#include \"Xpetra_MultiVector.hpp\"\n", "#include \"Xpetra_BlockedMultiVector.hpp\"\n", "#include \"Xpetra_BlockedVector.hpp\"\n", "#include \"Xpetra_MultiVectorFactory.hpp\"" ] }, { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "### Create a matrix object" ] }, { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "Let's create a matrix and wrap it as an ```Xpetra::CrsMatrixWrap``` object" ] }, { "cell_type": "code", "execution_count": 9, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [ { "data": { "text/plain": [ "(int) 100\n" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "int NumMyElements = 100;" ] }, { "cell_type": "code", "execution_count": 10, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [ { "data": { "text/plain": [ "(int) 0\n" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "Epetra_SerialComm Comm;\n", "Epetra_Map Map(-1, NumMyElements, 0, Comm);\n", "int NumGlobalElements = Map.NumGlobalElements();\n", "\n", "Epetra_CrsMatrix A(Copy, Map, 3);\n", "\n", "double negOne = -1.0;\n", "double posTwo = 2.0;\n", "for (int i=0; i &) @0x7f73d7d7e208\n" ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "Teuchos::RCP rcpA = Teuchos::rcpFromRef(A);\n", "Xpetra::EpetraCrsMatrixT xA(rcpA);\n", "Teuchos::RCP > xCrsMat = Teuchos::rcpFromRef(xA);\n", "Xpetra::CrsMatrixWrap xCrsWrap = Xpetra::CrsMatrixWrap(xCrsMat);" ] }, { "cell_type": "markdown", "metadata": { "collapsed": true, "deletable": true, "editable": true }, "source": [ "The ```xCrsWrap``` object contains the matrix object that can be used as input for *MueLu*." ] }, { "cell_type": "markdown", "metadata": { "collapsed": false, "deletable": true, "editable": true }, "source": [ "### Create a multigrid hierarchy" ] }, { "cell_type": "markdown", "metadata": { "collapsed": true, "deletable": true, "editable": true }, "source": [ "First, include the necessary header files:" ] }, { "cell_type": "code", "execution_count": 13, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [ { "data": { "text/plain": [] }, "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "#include \"MueLu_Level.hpp\"\n", "#include \"MueLu_MutuallyExclusiveTime.hpp\"\n", "#include \"MueLu_TimeMonitor.hpp\"\n", "#include \"MueLu_Hierarchy.hpp\"" ] }, { "cell_type": "markdown", "metadata": { "collapsed": false, "deletable": true, "editable": true }, "source": [ "Then, we create a new ```Hierarchy``` object. We use the input matrix ```xCrsWrap``` as parameter. The constructor automatically generates the first (finest) level and stores the provided matrix object as variable ```A``` on the finest level.\n", "
Note: there is also an empty constructor that you can use for more special cases. You can add new levels using the ```AddLevel``` routine and fill them with data by hand.
" ] }, { "cell_type": "code", "execution_count": 14, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [ { "data": { "text/plain": [ "(MueLu::Hierarchy &) @0x7f73d7d7e2f8\n" ] }, "execution_count": 14, "metadata": {}, "output_type": "execute_result" } ], "source": [ "MueLu::Hierarchy H(Teuchos::rcpFromRef(xCrsWrap));" ] }, { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "We set the maximum size for the coarsest level to $10$ and increase the verbosity output level to get more screen output." ] }, { "cell_type": "code", "execution_count": 15, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [ { "data": { "text/plain": [ "(void) @0x7fff2c5d7d40\n" ] }, "execution_count": 15, "metadata": {}, "output_type": "execute_result" } ], "source": [ "H.setDefaultVerbLevel(Teuchos::VERB_HIGH);\n", "H.SetMaxCoarseSize(10); " ] }, { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "You can access the finest level that has been created in the constructor using the ```Hierarchy::GetLevel(int)``` function. If you do not provide the level number it assumes the finest level. The ```MueLu::Level``` class also has a verbosity level for the output details related to the ```Level``` data." ] }, { "cell_type": "code", "execution_count": 16, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "LevelID = 0\n", " data name gen. factory addr. req keep type data req'd by \n", " -------------------- ------------------ ----- ----- --------------- -------------- --------------------\n", " A NoFactory 0 User Matrix available \n" ] }, { "data": { "text/plain": [ "(void) @0x7fff2c5d7d40\n" ] }, "execution_count": 16, "metadata": {}, "output_type": "execute_result" } ], "source": [ "Teuchos::RCP Finest = H.GetLevel();\n", "Finest->setDefaultVerbLevel(Teuchos::VERB_HIGH);\n", "Finest->print(std::cout, MueLu::Extreme);" ] }, { "cell_type": "markdown", "metadata": { "collapsed": true, "deletable": true, "editable": true }, "source": [ "As you can see, the finest level already contains the fine level operator ```A``` provided by the user. This is the ```xCrsWrap``` operator you provided in the constructor for the Hierarchy.\n", "
\n", "Note: Instead of providing the ```Xpetra::Matrix``` (or ```Xpetra::CrsMatrixWrap``` object) in the constructor, you can also use the *empty* standard constructor and add the fine level operator by hand using a code line like ```Finest->Set(\"A\",xCrsWrap);```.\n", "
" ] }, { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "#### A whirlwind through MueLu factories" ] }, { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "##### AmalgamationFactory" ] }, { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "The *AmalgamationFactory* takes the matrix ```A``` as input and amalgamates it. That is, if the matrix uses more than one DOFs per node, it builds the corresponding *amalgamated* node map and stores information on how to unamalgamate node-based information to dof-based information in the *UnamalgamationInfo* container." ] }, { "cell_type": "code", "execution_count": 17, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [ { "data": { "text/plain": [] }, "execution_count": 17, "metadata": {}, "output_type": "execute_result" } ], "source": [ "#include \"MueLu_AmalgamationFactory.hpp\"" ] }, { "cell_type": "code", "execution_count": 18, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [ { "data": { "text/plain": [ "(MueLu::AmalgamationFactory &) @0x7f73d7d7e4a0\n" ] }, "execution_count": 18, "metadata": {}, "output_type": "execute_result" } ], "source": [ "MueLu::AmalgamationFactory amalgFact;" ] }, { "cell_type": "markdown", "metadata": { "collapsed": true, "deletable": true, "editable": true }, "source": [ "##### CoalesceDropFactory" ] }, { "cell_type": "markdown", "metadata": { "collapsed": true, "deletable": true, "editable": true }, "source": [ "The *CoalesceDropFactory* actually generates the node-based graph given a dof-based matrix ```A``` and stores it as ```Graph``` in the ```Level``` container. It also accepts a threshold parameter for dropping small entries in ```A```. It may use information from the ```UnAmalgamationInfo``` container. " ] }, { "cell_type": "code", "execution_count": 19, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [ { "data": { "text/plain": [] }, "execution_count": 19, "metadata": {}, "output_type": "execute_result" } ], "source": [ "#include \"MueLu_CoalesceDropFactory.hpp\"" ] }, { "cell_type": "code", "execution_count": 20, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [ { "data": { "text/plain": [ "(MueLu::CoalesceDropFactory &) @0x7f73d7d7e5f0\n" ] }, "execution_count": 20, "metadata": {}, "output_type": "execute_result" } ], "source": [ "MueLu::CoalesceDropFactory coalFact;" ] }, { "cell_type": "code", "execution_count": 21, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [ { "data": { "text/plain": [ "(Teuchos::RCP > &) @0x7f73d7d7e750\n" ] }, "execution_count": 21, "metadata": {}, "output_type": "execute_result" } ], "source": [ "Teuchos::RCP > rcpCoalFact = Teuchos::rcpFromRef(coalFact);" ] }, { "cell_type": "markdown", "metadata": { "collapsed": true, "deletable": true, "editable": true }, "source": [ "
Note: In ```cling``` we create all factories on the stack and use ```Teuchos::rcpFromRef``` to define ```RCP``` pointers. We explicitly have to create an ```RCP``` pointer to a factory if we need it in several places.\n", "
" ] }, { "cell_type": "markdown", "metadata": { "collapsed": true, "deletable": true, "editable": true }, "source": [ "##### UncoupledAggregationFactory" ] }, { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "The *UncoupledAggregationFactory* builds the aggregates given a ```Graph``` and the ```DofsPerNode``` variable. ```DofsPerNode``` is provided by the *CoalesceDropFactory* and contains how many DOFs per node the matrix has." ] }, { "cell_type": "code", "execution_count": 22, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [ { "data": { "text/plain": [] }, "execution_count": 22, "metadata": {}, "output_type": "execute_result" } ], "source": [ "#include \"MueLu_UncoupledAggregationFactory.hpp\"" ] }, { "cell_type": "code", "execution_count": 23, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [ { "data": { "text/plain": [ "(MueLu::UncoupledAggregationFactory &) @0x7f73d7d7e768\n" ] }, "execution_count": 23, "metadata": {}, "output_type": "execute_result" } ], "source": [ "MueLu::UncoupledAggregationFactory aggFact;" ] }, { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "There are several ways how to define data dependencies between factories. You can (and sometimes have to) directly connect factories: for example, to use ```Graph``` and ```DofsPerNode``` generated by the previously defined *CoalesceDropFactory* ```rcpCoalFact``` in the *AggregationFactory* ```aggFact``` you use:" ] }, { "cell_type": "code", "execution_count": 24, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [ { "data": { "text/plain": [ "(void) @0x7fff2c5d7d40\n" ] }, "execution_count": 24, "metadata": {}, "output_type": "execute_result" } ], "source": [ "aggFact.SetFactory(\"Graph\", rcpCoalFact);\n", "aggFact.SetFactory(\"DofsPerNode\", rcpCoalFact);" ] }, { "cell_type": "markdown", "metadata": { "collapsed": true, "deletable": true, "editable": true }, "source": [ "
Note: In practice, it might be too complicated to define all necessary factory dependencies by hand. For example, most factories need ```A``` as input, which is generated on the previous level (by a *RAPFactory* object). *MueLu* provides a way to globally define which factory provides which data. That is, you can declare default factories which produce certain data. This functionality is provided by the *FactoryManager* which in detail will be introduced later.\n", "
" ] }, { "cell_type": "markdown", "metadata": { "collapsed": true, "deletable": true, "editable": true }, "source": [ "##### NullspaceFactory" ] }, { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "The *NullspaceFactory* provides constant vectors as default near-nullspace modes for the finest level. On the coarser levels it (usually) just pipes through the ```Nullspaace``` which is produced by the *TentativePFactory* (see below)" ] }, { "cell_type": "code", "execution_count": 25, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [ { "data": { "text/plain": [] }, "execution_count": 25, "metadata": {}, "output_type": "execute_result" } ], "source": [ "#include \"MueLu_NullspaceFactory.hpp\"" ] }, { "cell_type": "code", "execution_count": 26, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [ { "data": { "text/plain": [ "(MueLu::NullspaceFactory &) @0x7f73d7d7e8d0\n" ] }, "execution_count": 26, "metadata": {}, "output_type": "execute_result" } ], "source": [ "MueLu::NullspaceFactory nspFact;" ] }, { "cell_type": "code", "execution_count": 27, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [ { "data": { "text/plain": [ "(Teuchos::RCP > &) @0x7f73d7d7ea18\n" ] }, "execution_count": 27, "metadata": {}, "output_type": "execute_result" } ], "source": [ "Teuchos::RCP> rcpNspFact = Teuchos::rcpFromRef(nspFact);\n" ] }, { "cell_type": "markdown", "metadata": { "collapsed": true, "deletable": true, "editable": true }, "source": [ "##### TentativePFactory" ] }, { "cell_type": "markdown", "metadata": { "collapsed": true, "deletable": true, "editable": true }, "source": [ "The *TentativePFactory* build the tentative prolongation operator (with piecewise constant basis functions) using ```Aggregates``` and the fine level ```Nullspace```. It not only calculates and stores ```P``` on the coarsest level, but also generates the coarse null space (variable ```Nullspace``` on the coarse level)." ] }, { "cell_type": "code", "execution_count": 28, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [ { "data": { "text/plain": [] }, "execution_count": 28, "metadata": {}, "output_type": "execute_result" } ], "source": [ "#include \"MueLu_TentativePFactory.hpp\"" ] }, { "cell_type": "code", "execution_count": 29, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [ { "data": { "text/plain": [ "(MueLu::TentativePFactory &) @0x7f73d7d7ea30\n" ] }, "execution_count": 29, "metadata": {}, "output_type": "execute_result" } ], "source": [ "MueLu::TentativePFactory PFact;" ] }, { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "For demonstration purposes we explicitly set ```aggFact``` and ```nspFact``` to be the generating factories for the ```Aggregates``` and the fine level ```Nullspace```." ] }, { "cell_type": "code", "execution_count": 30, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [ { "data": { "text/plain": [ "(void) @0x7fff2c5d7d40\n" ] }, "execution_count": 30, "metadata": {}, "output_type": "execute_result" } ], "source": [ "PFact.SetFactory(\"Aggregates\", Teuchos::rcpFromRef(aggFact));\n", "PFact.SetFactory(\"Nullspace\", rcpNspFact);" ] }, { "cell_type": "markdown", "metadata": { "collapsed": true, "deletable": true, "editable": true }, "source": [ "So, it uses the ```Nullspace``` provided by the *NullspaceFactory* (see above), which on the finest levels creates a default set of near-nullspace vectors or uses user-provided null-space vectors. Then, the *TentativePFactory* creates a new coarse ```Nullspace``` on the coarse level (which is supposed to be the fine ```Nullspace``` for the next level).\n", "On the next coarser level, *NullspaceFactory* again is supposed to provide the fine level ```Nullspace``` (which actually has been generated by *TentativePFactory*). For doing so, *NullspaceFactory* just takes the coarse ```Nullspace``` from *TentativePFactory* and stores it as fine ```Nullspace``` generated by *NullspaceFactory*.\n", "\n", "For doing so, we have to tell the *NullspaceFactory* that it is supposed to use the ```Nullspace``` from the *TentativePFactory* as input. The *NullspaceFactory* contains some code for the finest level (to generate the default nullspace) to break through the circle dependency." ] }, { "cell_type": "code", "execution_count": 31, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [ { "data": { "text/plain": [ "(Teuchos::RCP > &) @0x7f73d7d7eb80\n" ] }, "execution_count": 31, "metadata": {}, "output_type": "execute_result" } ], "source": [ "Teuchos::RCP> rcpPFact = Teuchos::rcpFromRef(PFact);\n" ] }, { "cell_type": "code", "execution_count": 32, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [ { "data": { "text/plain": [ "(void) @0x7fff2c5d7d40\n" ] }, "execution_count": 32, "metadata": {}, "output_type": "execute_result" } ], "source": [ "rcpNspFact->SetFactory(\"Nullspace\", rcpPFact);" ] }, { "cell_type": "markdown", "metadata": { "collapsed": true, "deletable": true, "editable": true }, "source": [ "
Note:\n", "Here, for ```cling``` using the C++ interface, we can easily declare the circle dependency between *TentativePFactory* and *NullspaceFactory*. For a more general XML based input deck, we need a *FactoryManager*. Details will be discussed later.\n", "
" ] }, { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "##### TransPFactory" ] }, { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "The *TransPFactory* takes a prolongation operator ```P``` as input and stores its transposed as ```R```" ] }, { "cell_type": "code", "execution_count": 33, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [ { "data": { "text/plain": [] }, "execution_count": 33, "metadata": {}, "output_type": "execute_result" } ], "source": [ "#include \"MueLu_TransPFactory.hpp\"" ] }, { "cell_type": "code", "execution_count": 34, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [ { "data": { "text/plain": [ "(MueLu::TransPFactory &) @0x7f73d7d7eb98\n" ] }, "execution_count": 34, "metadata": {}, "output_type": "execute_result" } ], "source": [ "MueLu::TransPFactory RFact;" ] }, { "cell_type": "code", "execution_count": 35, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [ { "data": { "text/plain": [ "(void) @0x7fff2c5d7d40\n" ] }, "execution_count": 35, "metadata": {}, "output_type": "execute_result" } ], "source": [ "RFact.SetFactory(\"P\", Teuchos::rcpFromRef(PFact));" ] }, { "cell_type": "markdown", "metadata": { "collapsed": true, "deletable": true, "editable": true }, "source": [ "##### RAPFactory" ] }, { "cell_type": "markdown", "metadata": { "collapsed": true, "deletable": true, "editable": true }, "source": [ "The *RAPFactory* builds the triple Galerkin product to calculate the coarse level operator $A_c = RAP$. It takes the prolongation and restriction operators ```P``` and ```R``` as well as the fine level operator ```A``` as input and stores the coarse ```A``` on the coarse level." ] }, { "cell_type": "code", "execution_count": 36, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [ { "data": { "text/plain": [] }, "execution_count": 36, "metadata": {}, "output_type": "execute_result" } ], "source": [ "#include \"MueLu_RAPFactory.hpp\"" ] }, { "cell_type": "code", "execution_count": 37, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [ { "data": { "text/plain": [ "(MueLu::RAPFactory &) @0x7f73d7d7ece0\n" ] }, "execution_count": 37, "metadata": {}, "output_type": "execute_result" } ], "source": [ "MueLu::RAPFactory RAPFact;" ] }, { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "One can skip the following lines, if you have only one type of ```P``` and ```R``` whose associated factories are defined in a global *FactoryManager* (details later). Nevertheless, directly defining the dependencies does not hurt:" ] }, { "cell_type": "code", "execution_count": 38, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [ { "data": { "text/plain": [ "(void) @0x7fff2c5d7d40\n" ] }, "execution_count": 38, "metadata": {}, "output_type": "execute_result" } ], "source": [ "RAPFact.SetFactory(\"P\", Teuchos::rcpFromRef(PFact));" ] }, { "cell_type": "code", "execution_count": 39, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [ { "data": { "text/plain": [ "(void) @0x7fff2c5d7d40\n" ] }, "execution_count": 39, "metadata": {}, "output_type": "execute_result" } ], "source": [ "RAPFact.SetFactory(\"R\", Teuchos::rcpFromRef(RFact));" ] }, { "cell_type": "markdown", "metadata": { "collapsed": true, "deletable": true, "editable": true }, "source": [ "##### CoarseMapFactory" ] }, { "cell_type": "markdown", "metadata": { "collapsed": true, "deletable": true, "editable": true }, "source": [ "The *CoarseMapFactory* creates the coarse map which is used as domain map for the (tentative) prolongation operator. It is usually only used within the *TentativePFactory* and an average MueLu developer should never get into touch with it. Nevertheless, it is listed here for the sake of completeness of factories that you need somewhere when doing aggregation-based algebraic multigrid methods.\n", "It uses the ```Aggregates``` and ```Nullspace``` as input.\n", "\n", "Usually, you would not see the *CoarseMapFactory* at all, since it is usually used internally in the *TentativePFactory*. Nevertheless, it is there and plays an important role. In the usual case, the *FactoryManager* (details later) will automatically generate a default *CoarseMapFactory* for you that is used under the hood.\n", "\n", "
Note:\n", "The *FactoryManager* manages a list of (default) factories for all variables using ```RCP``` pointers. However, with ```cling``` it is not safe to have ```RCP``` objects within other objects, that may not live on the stack. The C++ interpreter may crash since ```RCP``` objects suddenly may have ran out of scope.\n", "
" ] }, { "cell_type": "code", "execution_count": 40, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [ { "data": { "text/plain": [] }, "execution_count": 40, "metadata": {}, "output_type": "execute_result" } ], "source": [ "#include \"MueLu_CoarseMapFactory.hpp\"" ] }, { "cell_type": "code", "execution_count": 41, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [ { "data": { "text/plain": [ "(MueLu::CoarseMapFactory &) @0x7f73d7d7ee48\n" ] }, "execution_count": 41, "metadata": {}, "output_type": "execute_result" } ], "source": [ "MueLu::CoarseMapFactory coarseMapFact;" ] }, { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "Again, just for demonstration purposes, we directly connect the ```nspFact``` and ```coarseMapFact``` using a call to ```SetFactory```" ] }, { "cell_type": "code", "execution_count": 42, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [ { "data": { "text/plain": [ "(void) nullptr\n" ] }, "execution_count": 42, "metadata": {}, "output_type": "execute_result" } ], "source": [ "coarseMapFact.SetFactory(\"Nullspace\", rcpNspFact);" ] }, { "cell_type": "markdown", "metadata": { "collapsed": true, "deletable": true, "editable": true }, "source": [ "##### SmootherFactory" ] }, { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "Last, but not least, the *SmootherFactory* handles level smoothers. More details about smoothers in *MueLu* can be found in a separate notebook." ] }, { "cell_type": "code", "execution_count": 43, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [ { "data": { "text/plain": [] }, "execution_count": 43, "metadata": {}, "output_type": "execute_result" } ], "source": [ "#include \"MueLu_SmootherFactory.hpp\"" ] }, { "cell_type": "code", "execution_count": 44, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [ { "data": { "text/plain": [ "(MueLu::SmootherFactory &) @0x7f739d65c000\n" ] }, "execution_count": 44, "metadata": {}, "output_type": "execute_result" } ], "source": [ "MueLu::SmootherFactory smootherFact;\n", "\n" ] }, { "cell_type": "markdown", "metadata": { "collapsed": true, "deletable": true, "editable": true }, "source": [ "#### The FactoryManager" ] }, { "cell_type": "markdown", "metadata": { "collapsed": true, "deletable": true, "editable": true }, "source": [ "In the previous section, we briefly introduced the minimal set of necessary factories to define an aggregation-based algebraic multigrid setup. We have seen, that one can define direct data dependencies using the ```Factory::SetFactory(VarName, rcpFactory)``` routine. Calling this routine defines ```VarName``` provided by ```rcpFactory``` to be used by the current factory.\n", "\n", "It is hard to define all data dependencies this way. In addition to ```SetFactory``` we can also globally define certain factories to provide certain data. The *FactoryManager* manages a list of classes associated to certain data. Unless directly defined, a *Factory* uses then the information from the *FactoryManager* to find the factory supposed to provide requested data." ] }, { "cell_type": "markdown", "metadata": { "collapsed": true, "deletable": true, "editable": true }, "source": [ "First, we create an empty *FactoryManager* object using" ] }, { "cell_type": "code", "execution_count": 45, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [ { "data": { "text/plain": [] }, "execution_count": 45, "metadata": {}, "output_type": "execute_result" } ], "source": [ "#include \"MueLu_FactoryManager.hpp\"" ] }, { "cell_type": "code", "execution_count": 46, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [ { "data": { "text/plain": [ "(MueLu::FactoryManager &) @0x7f739d65c178\n" ] }, "execution_count": 46, "metadata": {}, "output_type": "execute_result" } ], "source": [ "MueLu::FactoryManager M;" ] }, { "cell_type": "markdown", "metadata": { "collapsed": true, "deletable": true, "editable": true }, "source": [ "Then, for each variable name, we declare the (default) factory, which is providing the variable." ] }, { "cell_type": "code", "execution_count": 47, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [ { "data": { "text/plain": [ "(void) @0x7fff2c5d7d40\n" ] }, "execution_count": 47, "metadata": {}, "output_type": "execute_result" } ], "source": [ "M.SetFactory(\"Smoother\", Teuchos::rcpFromRef(smootherFact));\n", "M.SetFactory(\"CoarseSolver\", Teuchos::rcpFromRef(smootherFact));\n", "M.SetFactory(\"A\", Teuchos::rcpFromRef(RAPFact));\n", "M.SetFactory(\"P\", rcpPFact);\n", "M.SetFactory(\"R\", Teuchos::rcpFromRef(RFact));\n", "M.SetFactory(\"DofsPerNode\", rcpCoalFact);\n", "M.SetFactory(\"Graph\", rcpCoalFact);\n", "M.SetFactory(\"UnAmalgamationInfo\", Teuchos::rcpFromRef(amalgFact));\n", "M.SetFactory(\"Nullspace\", rcpPFact);\n", "M.SetFactory(\"Aggregates\", Teuchos::rcpFromRef(aggFact));\n", "M.SetFactory(\"CoarseMap\", Teuchos::rcpFromRef(coarseMapFact));" ] }, { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "For example: if not otherwise provided, the variable ```Nullspace``` is provided by the *TentativePFactory* ```PFact```. Or, even more important, variable ```A``` is calculated by the *RAPFactory*. Here, ```A``` primarily describes the coarse matrices ```A```, since ```A``` is provided by the user on the finest level.\n", "You may notice, that some factories (like the *CoalesceDropFactory*) produce several different variables (such as ```Graph``` and ```DofsPerNode```).\n", "\n", "For simple standard cases, one can get rid of most of the ```Factory::SetFactory``` calls. It should be sufficient to just declare all factories in the *FactoryManager* in one central place. Vice versa, making sure, that all direct dependencies are set using ```Factory::SetFactory```, one can reduce the number of entries in the *FactoryManager*." ] }, { "cell_type": "markdown", "metadata": { "collapsed": false, "deletable": true, "editable": true }, "source": [ "One can ask the *FactoryManager* to return the associated (default) factory for a given variable using, e.g." ] }, { "cell_type": "code", "execution_count": 48, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [ { "data": { "text/plain": [ "(const Teuchos::RCP::FactoryBase>) @0x2fc587b0\n" ] }, "execution_count": 48, "metadata": {}, "output_type": "execute_result" } ], "source": [ "M.GetFactory(\"A\");" ] }, { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "If the variable is not associated with a factory (through a ```FactoryManager::SetFactory``` call), the *FactoryManager* class will try to return hard-coded default factories (for most variable names).\n", "
Note:\n", "With ```cling``` this is technically not working. That is, in this notebook we have to explicitly creating instances of all the factories we need on the stack. We cannot use auto-generated default factories from the *FactoryManager*\n", "
" ] }, { "cell_type": "markdown", "metadata": { "collapsed": true, "deletable": true, "editable": true }, "source": [ "### TopSmootherFactory and TopRAPFactory" ] }, { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "There are two more rather special factories, which a MueLu user and a standard MueLu developer should not see. But they are there and one should be aware of their existence:\n", "- TopSmootherFactory\n", "- TopRAPFactory" ] }, { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "It is clear, that most multigrid methods consist of smoothers and transfer operators. Therefore, the variables ```Smoother``` and ```CoarseSolver``` as well as ```P``` and ```R``` are special in the sense, that you not only create them during the *Setup* phase, but you also make heavily use of them during the iteration phase. That is, it makes sense, to keep these data persistent and simplify access to it. This is done by the *TopRAPFactory* and *TopSmootherFactory*. These factories make sure, that above variables can be easily accessed on all levels without providing the generating factories. I.e., on all levels you just can use ```level.Get>(\"A\");``` and you will just get the matrix (same for ```Smoother```...)" ] }, { "cell_type": "code", "execution_count": 49, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [ { "data": { "text/plain": [ "(MueLu::TopSmootherFactory &) @0x7f739d65c278\n" ] }, "execution_count": 49, "metadata": {}, "output_type": "execute_result" } ], "source": [ "Teuchos::RCP> rcpM = Teuchos::rcpFromRef(M);\n", "\n", "#include \"MueLu_TopSmootherFactory.hpp\"\n", "MueLu::TopSmootherFactory ts(rcpM,\"Smoother\");" ] }, { "cell_type": "code", "execution_count": 50, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [ { "data": { "text/plain": [ "(MueLu::TopSmootherFactory &) @0x7f739d65c3f0\n" ] }, "execution_count": 50, "metadata": {}, "output_type": "execute_result" } ], "source": [ "MueLu::TopSmootherFactory tsc(rcpM,\"CoarseSolver\");" ] }, { "cell_type": "markdown", "metadata": { "collapsed": true, "deletable": true, "editable": true }, "source": [ "Let's create a ```TopRAPFactory``` object:" ] }, { "cell_type": "code", "execution_count": 52, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [ { "data": { "text/plain": [] }, "execution_count": 52, "metadata": {}, "output_type": "execute_result" } ], "source": [ "#include \"MueLu_TopRAPFactory.hpp\"" ] }, { "cell_type": "code", "execution_count": 53, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [ { "data": { "text/plain": [ "(MueLu::TopRAPFactory &) @0x7f739d65c568\n" ] }, "execution_count": 53, "metadata": {}, "output_type": "execute_result" } ], "source": [ "MueLu::TopRAPFactory tr(rcpM);" ] }, { "cell_type": "markdown", "metadata": { "collapsed": true, "deletable": true, "editable": true }, "source": [ "Again, you should never really need to use these factories directly (unless you are modifying the ```Hierarchy``` in special ways)." ] }, { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "### Hierarchy::Setup - let's do multigrid" ] }, { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "With the *FactoryManager* set up using all the previously defined *Factories*, we finally can call the ```Setup``` routine to generate the multigrid hierarchy.\n", "\n", "For example, with ```Hierarchy::Setup(M,0,1);``` we create a 1-level method using the *FactoryManager* ```M```." ] }, { "cell_type": "code", "execution_count": 54, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Setup (MueLu::Hierarchy)\n", " Clearing old data (if any)\n", " A0 size = 100 x 100, nnz = 298\n", " A0 Load balancing info\n", " A0 # active processes: 1/1\n", " A0 # rows per proc : avg = 1.00e+02, dev = 0.0%, min = +0.0%, max = +0.0%\n", " A0 # nnz per proc : avg = 2.98e+02, dev = 0.0%, min = +0.0%, max = +0.0%\n", " Setup loop: startLevel = 0, lastLevel = 0 (stop if numLevels = 1 or Ac.size() < 10)\n", " Level 0\n", " \n", " --------------------------------------------------------------------------------\n", " --- Multigrid Summary ---\n", " --------------------------------------------------------------------------------\n", " Number of levels = 1\n", " Operator complexity = 1.00\n", " Smoother complexity = 0.00\n", " Cycle type = V\n", " \n", " level rows nnz nnz/row c ratio procs\n", " 0 100 298 2.98 1\n", " \n", " Smoother (level 0) pre : no smoother\n", " Smoother (level 0) post : no smoother\n", " \n" ] }, { "data": { "text/plain": [ "(void) @0x7fff2c5d7d40\n" ] }, "execution_count": 54, "metadata": {}, "output_type": "execute_result" } ], "source": [ "H.Setup(M,0,1);" ] }, { "cell_type": "markdown", "metadata": { "collapsed": false, "deletable": true, "editable": true }, "source": [ "Obviously, we built a one-level method with no smoother. We can build a two-level method (starting level = 0, ending level = 1) using:" ] }, { "cell_type": "code", "execution_count": 55, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Setup (MueLu::Hierarchy)\n", " Clearing old data (if any)\n", " A0 size = 100 x 100, nnz = 298\n", " A0 Load balancing info\n", " A0 # active processes: 1/1\n", " A0 # rows per proc : avg = 1.00e+02, dev = 0.0%, min = +0.0%, max = +0.0%\n", " A0 # nnz per proc : avg = 2.98e+02, dev = 0.0%, min = +0.0%, max = +0.0%\n", " Setup loop: startLevel = 0, lastLevel = 1 (stop if numLevels = 2 or Ac.size() < 10)\n", " Level 0\n", " Level 1\n", " Build (MueLu::TentativePFactory)\n", " Build (MueLu::UncoupledAggregationFactory)\n", " Build (MueLu::CoalesceDropFactory)\n", " Build (MueLu::AmalgamationFactory)\n", " \n", " ******* WARNING *******\n", " AmalagamationFactory::Build(): no striding information available. Use blockdim=1 with offset=0\n", " lightweight wrap = 1\n", " algorithm = \"classical\": threshold = 0, blocksize = 1\n", " \n", " ******* WARNING *******\n", " Level::Set: unable to store \"Filtering\" generated by factory 0x7f73d7d7e5f0 on level 0, as it has not been requested and no keep flags were set for it\n", " Detected 0 Dirichlet nodes\n", " Number of dropped entries in unamalgamated matrix graph: 0/298 (0%)\n", " Algo \"Phase - (Dirichlet)\"\n", " BuildAggregates (Phase - (Dirichlet))\n", " aggregated : 0 (phase), 0/100 [0.00%] (total)\n", " remaining : 100\n", " aggregates : 0 (phase), 0 (total)\n", " Algo \"Phase 1 (main)\"\n", " BuildAggregates (Phase 1 (main))\n", " aggregated : 100 (phase), 100/100 [100.00%] (total)\n", " remaining : 0\n", " aggregates : 34 (phase), 34 (total)\n", " Algo \"Phase 2a (secondary)\"\n", " BuildAggregates (Phase 2a (secondary))\n", " aggregated : 0 (phase), 100/100 [100.00%] (total)\n", " remaining : 0\n", " aggregates : 0 (phase), 34 (total)\n", " Algo \"Phase 2b (expansion)\"\n", " BuildAggregates (Phase 2b (expansion))\n", " aggregated : 0 (phase), 100/100 [100.00%] (total)\n", " remaining : 0\n", " aggregates : 0 (phase), 34 (total)\n", " Algo \"Phase 3 (cleanup)\"\n", " BuildAggregates (Phase 3 (cleanup))\n", " aggregated : 0 (phase), 100/100 [100.00%] (total)\n", " remaining : 0\n", " aggregates : 0 (phase), 34 (total)\n", " \"UC\": MueLu::Aggregates{nGlobalAggregates = 34}\n", " Nullspace factory (MueLu::NullspaceFactory)\n", " Generating canonical nullspace: dimension = 1\n", " Build (MueLu::CoarseMapFactory)\n", " domainGIDOffset: 0 block size: 1 stridedBlockId: -1\n", " Column map is consistent with the row map, good.\n", " TentativePFactory : aggregates do not cross process boundaries\n", " \n", " ******* WARNING *******\n", " Level::Set: unable to store \"Nullspace\" generated by factory 0x7f73d7d7ea30 on level 1, as it has not been requested and no keep flags were set for it\n", " Ptent size = 100 x 34, nnz = 100\n", " Ptent Load balancing info\n", " Ptent # active processes: 1/1\n", " Ptent # rows per proc : avg = 1.00e+02, dev = 0.0%, min = +0.0%, max = +0.0%\n", " Ptent # nnz per proc : avg = 1.00e+02, dev = 0.0%, min = +0.0%, max = +0.0%\n", " Transpose P (MueLu::TransPFactory)\n", " R size = 34 x 100, nnz = 100\n", " R Load balancing info\n", " R # active processes: 1/1\n", " R # rows per proc : avg = 3.40e+01, dev = 0.0%, min = +0.0%, max = +0.0%\n", " R # nnz per proc : avg = 1.00e+02, dev = 0.0%, min = +0.0%, max = +0.0%\n", " Computing Ac (MueLu::RAPFactory)\n", " MxM: A x P\n", " MxM: R x (AP) (explicit)\n", " Ac size = 34 x 34, nnz = 100\n", " Ac Load balancing info\n", " Ac # active processes: 1/1\n", " Ac # rows per proc : avg = 3.40e+01, dev = 0.0%, min = +0.0%, max = +0.0%\n", " Ac # nnz per proc : avg = 1.00e+02, dev = 0.0%, min = +0.0%, max = +0.0%\n", " \n", " ******* WARNING *******\n", " Level::Set: unable to store \"AP reuse data\" generated by factory 0x7f73d7d7ece0 on level 1, as it has not been requested and no keep flags were set for it\n", " \n", " ******* WARNING *******\n", " Level::Set: unable to store \"RAP reuse data\" generated by factory 0x7f73d7d7ece0 on level 1, as it has not been requested and no keep flags were set for it\n", " \n", " --------------------------------------------------------------------------------\n", " --- Multigrid Summary ---\n", " --------------------------------------------------------------------------------\n", " Number of levels = 2\n", " Operator complexity = 1.34\n", " Smoother complexity = 0.00\n", " Cycle type = V\n", " \n", " level rows nnz nnz/row c ratio procs\n", " 0 100 298 2.98 1\n", " 1 34 100 2.94 2.94 1\n", " \n", " Smoother (level 0) pre : no smoother\n", " Smoother (level 0) post : no smoother\n", " \n", " Smoother (level 1) pre : no smoother\n", " Smoother (level 1) post : no smoother\n", " \n" ] }, { "data": { "text/plain": [ "(void) @0x7fff2c5d7d40\n" ] }, "execution_count": 55, "metadata": {}, "output_type": "execute_result" } ], "source": [ "H.Setup(M,0,2);" ] }, { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "We got a two-level method with no smoothers. Of course, without level smoothers this would be a very inefficient multigrid method.\n", "\n", "Why does it not create level smoothers even though we extra defined a ```SmootherFactory``` in the *FactoryManager*?" ] }, { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "### Level smoothers in MueLu" ] }, { "cell_type": "markdown", "metadata": { "collapsed": true, "deletable": true, "editable": true }, "source": [ "Let's add level smoothers:" ] }, { "cell_type": "code", "execution_count": 58, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [ { "data": { "text/plain": [] }, "execution_count": 58, "metadata": {}, "output_type": "execute_result" } ], "source": [ "#include \"Teuchos_ParameterList.hpp\"" ] }, { "cell_type": "code", "execution_count": 59, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [ { "data": { "text/plain": [ "(Teuchos::ParameterList &) {}\n" ] }, "execution_count": 59, "metadata": {}, "output_type": "execute_result" } ], "source": [ "Teuchos::ParameterList smooParams;\n" ] }, { "cell_type": "code", "execution_count": 60, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [ { "data": { "text/plain": [ "(Teuchos::ParameterList &) { \"relaxation: type\" => @0x38e38f58, \"relaxation: sweeps\" => @0x38e38fa0, \"relaxation: damping factor\" => @0x38e38fe8 }\n" ] }, "execution_count": 60, "metadata": {}, "output_type": "execute_result" } ], "source": [ "smooParams.set(\"type\", Teuchos::ParameterEntry(\"RELAXATION\"));\n", "Teuchos::ParameterList& subSmooParams = smooParams.sublist(\"ParamterList\");\n", "subSmooParams.set(\"relaxation: type\", \"Symmetric Gauss-Seidel\");\n", "subSmooParams.set(\"relaxation: sweeps\",1);\n", "subSmooParams.set(\"relaxation: damping factor\",1.0);" ] }, { "cell_type": "code", "execution_count": 61, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "type = RELAXATION [unused] [unused]\n", "ParamterList -> \n", " relaxation: type = Symmetric Gauss-Seidel [unused]\n", " relaxation: sweeps = 1 [unused]\n", " relaxation: damping factor = 1 [unused]\n", "\n" ] }, { "data": { "text/plain": [ "(std::basic_ostream >::__ostream_type &) @0x7f3c65c6f700\n" ] }, "execution_count": 61, "metadata": {}, "output_type": "execute_result" } ], "source": [ "std::cout << smooParams << std::endl;" ] }, { "cell_type": "code", "execution_count": 62, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [ { "data": { "text/plain": [] }, "execution_count": 62, "metadata": {}, "output_type": "execute_result" } ], "source": [ "#include \"MueLu_TrilinosSmoother.hpp\"" ] }, { "cell_type": "code", "execution_count": 63, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [ { "data": { "text/plain": [ "(MueLu::TrilinosSmoother &) @0x7f3c2f808798\n" ] }, "execution_count": 63, "metadata": {}, "output_type": "execute_result" } ], "source": [ "MueLu::TrilinosSmoother trSmoother(\"RELAXATION\", subSmooParams);\n", "\n" ] }, { "cell_type": "code", "execution_count": 64, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [ { "data": { "text/plain": [ "(void) @0x7ffe046c38f0\n" ] }, "execution_count": 64, "metadata": {}, "output_type": "execute_result" } ], "source": [ "PFact.DisableMultipleCheckGlobally();" ] }, { "cell_type": "code", "execution_count": 65, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [ { "data": { "text/plain": [ "(void) @0x7ffe046c38f0\n" ] }, "execution_count": 65, "metadata": {}, "output_type": "execute_result" } ], "source": [ "\n", "smootherFact.SetSmootherPrototypes(Teuchos::rcpFromRef(trSmoother));" ] }, { "cell_type": "code", "execution_count": 66, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Setup (MueLu::Hierarchy)\n", " Clearing old data (if any)\n", " A0 size = 100 x 100, nnz = 298\n", " A0 Load balancing info\n", " A0 # active processes: 1/1\n", " A0 # rows per proc : avg = 1.00e+02, dev = 0.0%, min = +0.0%, max = +0.0%\n", " A0 # nnz per proc : avg = 2.98e+02, dev = 0.0%, min = +0.0%, max = +0.0%\n", " Setup loop: startLevel = 0, lastLevel = 1 (stop if numLevels = 2 or Ac.size() < 10)\n", " Level 0\n", " Setup Smoother (MueLu::IfpackSmoother{type = point relaxation stand-alone})\n", " IFPACK (Local SGS, sweeps=1, damping=1)\n", " Level 1\n", " Build (MueLu::TentativePFactory)\n", " Build (MueLu::UncoupledAggregationFactory)\n", " Build (MueLu::CoalesceDropFactory)\n", " PreDropFunctionConstVal: threshold = 0\n", " Build (MueLu::AmalgamationFactory)\n", " \n", " ******* WARNING *******\n", " AmalagamationFactory::Build(): no striding information available. Use blockdim=1 with offset=0\n", " lightweight wrap = 1\n", " algorithm = \"classical\": threshold = 0.00, blocksize = 1\n", " \n", " ******* WARNING *******\n", " Level::Set: unable to store \"Filtering\" generated by factory 0x7f3c6df2a5f0 on level 0, as it has not been requested and no keep flags were set for it\n", " Detected 0 Dirichlet nodes\n", " Number of dropped entries in unamalgamated matrix graph: 0/298 (0.00%)\n", " Algo \"Phase - (Dirichlet)\"\n", " BuildAggregates (Phase - (Dirichlet))\n", " aggregated : 0 (phase), 0/100 [0.00%] (total)\n", " remaining : 100\n", " aggregates : 0 (phase), 0 (total)\n", " Algo \"Phase 1 (main)\"\n", " BuildAggregates (Phase 1 (main))\n", " aggregated : 100 (phase), 100/100 [100.00%] (total)\n", " remaining : 0\n", " aggregates : 34 (phase), 34 (total)\n", " Algo \"Phase 2a (secondary)\"\n", " BuildAggregates (Phase 2a (secondary))\n", " aggregated : 0 (phase), 100/100 [100.00%] (total)\n", " remaining : 0\n", " aggregates : 0 (phase), 34 (total)\n", " Algo \"Phase 2b (expansion)\"\n", " BuildAggregates (Phase 2b (expansion))\n", " aggregated : 0 (phase), 100/100 [100.00%] (total)\n", " remaining : 0\n", " aggregates : 0 (phase), 34 (total)\n", " Algo \"Phase 3 (cleanup)\"\n", " BuildAggregates (Phase 3 (cleanup))\n", " aggregated : 0 (phase), 100/100 [100.00%] (total)\n", " remaining : 0\n", " aggregates : 0 (phase), 34 (total)\n", " \"UC\": MueLu::Aggregates{nGlobalAggregates = 34}\n", " Nullspace factory (MueLu::NullspaceFactory)\n", " Generating canonical nullspace: dimension = 1\n", " Build (MueLu::CoarseMapFactory)\n", " domainGIDOffset: 0 block size: 1 stridedBlockId: -1\n", " Column map is consistent with the row map, good.\n", " TentativePFactory : aggregates do not cross process boundaries\n", " \n", " ******* WARNING *******\n", " Level::Set: unable to store \"Nullspace\" generated by factory 0x7f3c6df2aa30 on level 1, as it has not been requested and no keep flags were set for it\n", " Ptent size = 100 x 34, nnz = 100\n", " Ptent Load balancing info\n", " Ptent # active processes: 1/1\n", " Ptent # rows per proc : avg = 1.00e+02, dev = 0.0%, min = +0.0%, max = +0.0%\n", " Ptent # nnz per proc : avg = 1.00e+02, dev = 0.0%, min = +0.0%, max = +0.0%\n", " Transpose P (MueLu::TransPFactory)\n", " R size = 34 x 100, nnz = 100\n", " R Load balancing info\n", " R # active processes: 1/1\n", " R # rows per proc : avg = 3.40e+01, dev = 0.0%, min = +0.0%, max = +0.0%\n", " R # nnz per proc : avg = 1.00e+02, dev = 0.0%, min = +0.0%, max = +0.0%\n", " Computing Ac (MueLu::RAPFactory)\n", " MxM: A x P\n", " MxM: R x (AP) (explicit)\n", " Ac size = 34 x 34, nnz = 100\n", " Ac Load balancing info\n", " Ac # active processes: 1/1\n", " Ac # rows per proc : avg = 3.40e+01, dev = 0.0%, min = +0.0%, max = +0.0%\n", " Ac # nnz per proc : avg = 1.00e+02, dev = 0.0%, min = +0.0%, max = +0.0%\n", " \n", " ******* WARNING *******\n", " Level::Set: unable to store \"AP reuse data\" generated by factory 0x7f3c6df2ace0 on level 1, as it has not been requested and no keep flags were set for it\n", " \n", " ******* WARNING *******\n", " Level::Set: unable to store \"RAP reuse data\" generated by factory 0x7f3c6df2ace0 on level 1, as it has not been requested and no keep flags were set for it\n", " Setup Smoother (MueLu::IfpackSmoother{type = point relaxation stand-alone})\n", " IFPACK (Local SGS, sweeps=1, damping=1)\n", " \n", " ******* WARNING *******\n", " Level::Set: unable to store \"PostSmoother\" generated by factory 0x7f3c2f808000 on level 1, as it has not been requested and no keep flags were set for it\n", " \n", " --------------------------------------------------------------------------------\n", " --- Multigrid Summary ---\n", " --------------------------------------------------------------------------------\n", " Number of levels = 2\n", " Operator complexity = 1.34\n", " Smoother complexity = 0.00\n", " Cycle type = V\n", " \n", " level rows nnz nnz/row c ratio procs\n", " 0 100 298 2.98 1\n", " 1 34 100 2.94 2.94 1\n", " \n", " Smoother (level 0) both : IFPACK (Local SGS, sweeps=1, damping=1)\n", " \n", " Smoother (level 1) pre : IFPACK (Local SGS, sweeps=1, damping=1)\n", " Smoother (level 1) post : no smoother\n", " \n" ] }, { "data": { "text/plain": [ "(void) @0x7ffe046c38f0\n" ] }, "execution_count": 66, "metadata": {}, "output_type": "execute_result" } ], "source": [ "H.Setup(M,0,2);" ] }, { "cell_type": "code", "execution_count": 67, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Setup (MueLu::Hierarchy)\n", " Clearing old data (if any)\n", " A0 size = 100 x 100, nnz = 298\n", " A0 Load balancing info\n", " A0 # active processes: 1/1\n", " A0 # rows per proc : avg = 1.00e+02, dev = 0.0%, min = +0.0%, max = +0.0%\n", " A0 # nnz per proc : avg = 2.98e+02, dev = 0.0%, min = +0.0%, max = +0.0%\n", " Setup loop: startLevel = 0, lastLevel = 2 (stop if numLevels = 3 or Ac.size() < 10)\n", " Level 0\n", " Setup Smoother (MueLu::IfpackSmoother{type = point relaxation stand-alone})\n", " IFPACK (Local SGS, sweeps=1, damping=1)\n", " Level 1\n", " Build (MueLu::TentativePFactory)\n", " Build (MueLu::UncoupledAggregationFactory)\n", " Build (MueLu::CoalesceDropFactory)\n", " PreDropFunctionConstVal: threshold = 0\n", " Build (MueLu::AmalgamationFactory)\n", " \n", " ******* WARNING *******\n", " AmalagamationFactory::Build(): no striding information available. Use blockdim=1 with offset=0\n", " lightweight wrap = 1\n", " algorithm = \"classical\": threshold = 0.00, blocksize = 1\n", " \n", " ******* WARNING *******\n", " Level::Set: unable to store \"Filtering\" generated by factory 0x7f3c6df2a5f0 on level 0, as it has not been requested and no keep flags were set for it\n", " Detected 0 Dirichlet nodes\n", " Number of dropped entries in unamalgamated matrix graph: 0/298 (0.00%)\n", " Algo \"Phase - (Dirichlet)\"\n", " BuildAggregates (Phase - (Dirichlet))\n", " aggregated : 0 (phase), 0/100 [0.00%] (total)\n", " remaining : 100\n", " aggregates : 0 (phase), 0 (total)\n", " Algo \"Phase 1 (main)\"\n", " BuildAggregates (Phase 1 (main))\n", " aggregated : 100 (phase), 100/100 [100.00%] (total)\n", " remaining : 0\n", " aggregates : 34 (phase), 34 (total)\n", " Algo \"Phase 2a (secondary)\"\n", " BuildAggregates (Phase 2a (secondary))\n", " aggregated : 0 (phase), 100/100 [100.00%] (total)\n", " remaining : 0\n", " aggregates : 0 (phase), 34 (total)\n", " Algo \"Phase 2b (expansion)\"\n", " BuildAggregates (Phase 2b (expansion))\n", " aggregated : 0 (phase), 100/100 [100.00%] (total)\n", " remaining : 0\n", " aggregates : 0 (phase), 34 (total)\n", " Algo \"Phase 3 (cleanup)\"\n", " BuildAggregates (Phase 3 (cleanup))\n", " aggregated : 0 (phase), 100/100 [100.00%] (total)\n", " remaining : 0\n", " aggregates : 0 (phase), 34 (total)\n", " \"UC\": MueLu::Aggregates{nGlobalAggregates = 34}\n", " Nullspace factory (MueLu::NullspaceFactory)\n", " Generating canonical nullspace: dimension = 1\n", " Build (MueLu::CoarseMapFactory)\n", " domainGIDOffset: 0 block size: 1 stridedBlockId: -1\n", " Column map is consistent with the row map, good.\n", " TentativePFactory : aggregates do not cross process boundaries\n", " Ptent size = 100 x 34, nnz = 100\n", " Ptent Load balancing info\n", " Ptent # active processes: 1/1\n", " Ptent # rows per proc : avg = 1.00e+02, dev = 0.0%, min = +0.0%, max = +0.0%\n", " Ptent # nnz per proc : avg = 1.00e+02, dev = 0.0%, min = +0.0%, max = +0.0%\n", " Transpose P (MueLu::TransPFactory)\n", " R size = 34 x 100, nnz = 100\n", " R Load balancing info\n", " R # active processes: 1/1\n", " R # rows per proc : avg = 3.40e+01, dev = 0.0%, min = +0.0%, max = +0.0%\n", " R # nnz per proc : avg = 1.00e+02, dev = 0.0%, min = +0.0%, max = +0.0%\n", " Computing Ac (MueLu::RAPFactory)\n", " MxM: A x P\n", " MxM: R x (AP) (explicit)\n", " Ac size = 34 x 34, nnz = 100\n", " Ac Load balancing info\n", " Ac # active processes: 1/1\n", " Ac # rows per proc : avg = 3.40e+01, dev = 0.0%, min = +0.0%, max = +0.0%\n", " Ac # nnz per proc : avg = 1.00e+02, dev = 0.0%, min = +0.0%, max = +0.0%\n", " \n", " ******* WARNING *******\n", " Level::Set: unable to store \"AP reuse data\" generated by factory 0x7f3c6df2ace0 on level 1, as it has not been requested and no keep flags were set for it\n", " \n", " ******* WARNING *******\n", " Level::Set: unable to store \"RAP reuse data\" generated by factory 0x7f3c6df2ace0 on level 1, as it has not been requested and no keep flags were set for it\n", " Setup Smoother (MueLu::IfpackSmoother{type = point relaxation stand-alone})\n", " IFPACK (Local SGS, sweeps=1, damping=1)\n", " Level 2\n", " Build (MueLu::TentativePFactory)\n", " Build (MueLu::UncoupledAggregationFactory)\n", " Build (MueLu::CoalesceDropFactory)\n", " PreDropFunctionConstVal: threshold = 0\n", " Build (MueLu::AmalgamationFactory)\n", " AmalagamationFactory::Build(): found fullblocksize=1 and stridedblocksize=1 from strided maps. offset=0\n", " lightweight wrap = 1\n", " algorithm = \"classical\": threshold = 0.00, blocksize = 1\n", " \n", " ******* WARNING *******\n", " Level::Set: unable to store \"Filtering\" generated by factory 0x7f3c6df2a5f0 on level 1, as it has not been requested and no keep flags were set for it\n", " Detected 0 Dirichlet nodes\n", " Number of dropped entries in unamalgamated matrix graph: 0/100 (0.00%)\n", " Algo \"Phase - (Dirichlet)\"\n", " BuildAggregates (Phase - (Dirichlet))\n", " aggregated : 0 (phase), 0/34 [0.00%] (total)\n", " remaining : 34\n", " aggregates : 0 (phase), 0 (total)\n", " Algo \"Phase 1 (main)\"\n", " BuildAggregates (Phase 1 (main))\n", " aggregated : 34 (phase), 34/34 [100.00%] (total)\n", " remaining : 0\n", " aggregates : 12 (phase), 12 (total)\n", " Algo \"Phase 2a (secondary)\"\n", " BuildAggregates (Phase 2a (secondary))\n", " aggregated : 0 (phase), 34/34 [100.00%] (total)\n", " remaining : 0\n", " aggregates : 0 (phase), 12 (total)\n", " Algo \"Phase 2b (expansion)\"\n", " BuildAggregates (Phase 2b (expansion))\n", " aggregated : 0 (phase), 34/34 [100.00%] (total)\n", " remaining : 0\n", " aggregates : 0 (phase), 12 (total)\n", " Algo \"Phase 3 (cleanup)\"\n", " BuildAggregates (Phase 3 (cleanup))\n", " aggregated : 0 (phase), 34/34 [100.00%] (total)\n", " remaining : 0\n", " aggregates : 0 (phase), 12 (total)\n", " \"UC\": MueLu::Aggregates{nGlobalAggregates = 12}\n", " Nullspace factory (MueLu::NullspaceFactory)\n", " Build (MueLu::CoarseMapFactory)\n", " domainGIDOffset: 0 block size: 1 stridedBlockId: -1\n", " Column map is consistent with the row map, good.\n", " TentativePFactory : aggregates do not cross process boundaries\n", " \n", " ******* WARNING *******\n", " Level::Set: unable to store \"Nullspace\" generated by factory 0x7f3c6df2aa30 on level 2, as it has not been requested and no keep flags were set for it\n", " Ptent size = 34 x 12, nnz = 34\n", " Ptent Load balancing info\n", " Ptent # active processes: 1/1\n", " Ptent # rows per proc : avg = 3.40e+01, dev = 0.0%, min = +0.0%, max = +0.0%\n", " Ptent # nnz per proc : avg = 3.40e+01, dev = 0.0%, min = +0.0%, max = +0.0%\n", " Transpose P (MueLu::TransPFactory)\n", " R size = 12 x 34, nnz = 34\n", " R Load balancing info\n", " R # active processes: 1/1\n", " R # rows per proc : avg = 1.20e+01, dev = 0.0%, min = +0.0%, max = +0.0%\n", " R # nnz per proc : avg = 3.40e+01, dev = 0.0%, min = +0.0%, max = +0.0%\n", " Computing Ac (MueLu::RAPFactory)\n", " MxM: A x P\n", " MxM: R x (AP) (explicit)\n", " Ac size = 12 x 12, nnz = 34\n", " Ac Load balancing info\n", " Ac # active processes: 1/1\n", " Ac # rows per proc : avg = 1.20e+01, dev = 0.0%, min = +0.0%, max = +0.0%\n", " Ac # nnz per proc : avg = 3.40e+01, dev = 0.0%, min = +0.0%, max = +0.0%\n", " \n", " ******* WARNING *******\n", " Level::Set: unable to store \"AP reuse data\" generated by factory 0x7f3c6df2ace0 on level 2, as it has not been requested and no keep flags were set for it\n", " \n", " ******* WARNING *******\n", " Level::Set: unable to store \"RAP reuse data\" generated by factory 0x7f3c6df2ace0 on level 2, as it has not been requested and no keep flags were set for it\n", " Setup Smoother (MueLu::IfpackSmoother{type = point relaxation stand-alone})\n", " IFPACK (Local SGS, sweeps=1, damping=1)\n", " \n", " ******* WARNING *******\n", " Level::Set: unable to store \"PostSmoother\" generated by factory 0x7f3c2f808000 on level 2, as it has not been requested and no keep flags were set for it\n", " \n", " --------------------------------------------------------------------------------\n", " --- Multigrid Summary ---\n", " --------------------------------------------------------------------------------\n", " Number of levels = 3\n", " Operator complexity = 1.45\n", " Smoother complexity = 0.00\n", " Cycle type = V\n", " \n", " level rows nnz nnz/row c ratio procs\n", " 0 100 298 2.98 1\n", " 1 34 100 2.94 2.94 1\n", " 2 12 34 2.83 2.83 1\n", " \n", " Smoother (level 0) both : IFPACK (Local SGS, sweeps=1, damping=1)\n", " \n", " Smoother (level 1) both : IFPACK (Local SGS, sweeps=1, damping=1)\n", " \n", " Smoother (level 2) pre : IFPACK (Local SGS, sweeps=1, damping=1)\n", " Smoother (level 2) post : no smoother\n", " \n" ] }, { "data": { "text/plain": [ "(void) @0x7ffe046c38f0\n" ] }, "execution_count": 67, "metadata": {}, "output_type": "execute_result" } ], "source": [ "H.Setup(M,0,3);" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true, "deletable": true, "editable": true }, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "C++11", "language": "", "name": "cling-cpp11" }, "language_info": { "codemirror_mode": "text/x-c++src", "file_extension": ".c++", "mimetype": " text/x-c++src", "name": "c++" } }, "nbformat": 4, "nbformat_minor": 0 }