SundancePCDPreconditioner.cpp
Go to the documentation of this file.
00001 /* @HEADER@ */
00002 // ************************************************************************
00003 // 
00004 //                             Sundance
00005 //                 Copyright 2011 Sandia Corporation
00006 // 
00007 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
00008 // the U.S. Government retains certain rights in this software.
00009 //
00010 // Redistribution and use in source and binary forms, with or without
00011 // modification, are permitted provided that the following conditions are
00012 // met:
00013 //
00014 // 1. Redistributions of source code must retain the above copyright
00015 // notice, this list of conditions and the following disclaimer.
00016 //
00017 // 2. Redistributions in binary form must reproduce the above copyright
00018 // notice, this list of conditions and the following disclaimer in the
00019 // documentation and/or other materials provided with the distribution.
00020 //
00021 // 3. Neither the name of the Corporation nor the names of the
00022 // contributors may be used to endorse or promote products derived from
00023 // this software without specific prior written permission.
00024 //
00025 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
00026 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00027 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00028 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
00029 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00030 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00031 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00032 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00033 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00034 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00035 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00036 //
00037 // Questions? Contact Kevin Long (kevin.long@ttu.edu)
00038 // 
00039 
00040 /* @HEADER@ */
00041 
00042 
00043 #include "SundancePCDPreconditioner.hpp"
00044 #include "Sundance.hpp"
00045 #include "PlayaLinearSolverBuilder.hpp"
00046 #include "PlayaLinearSolverImpl.hpp"
00047 #include "PlayaSimpleIdentityOpDecl.hpp"
00048 #include "PlayaSimpleIdentityOpImpl.hpp"
00049 #include "PlayaSimpleComposedOpDecl.hpp"
00050 #include "PlayaSimpleComposedOpImpl.hpp"
00051 #include "PlayaSimpleBlockOpDecl.hpp"
00052 #include "PlayaSimpleBlockOpImpl.hpp"
00053 #include "PlayaSimpleScaledOpDecl.hpp"
00054 #include "PlayaSimpleScaledOpImpl.hpp"
00055 #include "PlayaGenericRightPreconditioner.hpp"
00056 #include "PlayaLinearCombinationImpl.hpp"
00057 #include "PlayaInverseOperatorDecl.hpp"
00058 #include "PlayaInverseOperatorImpl.hpp"
00059 
00060 using namespace Playa;
00061 using namespace Sundance;
00062 
00063 PCDPreconditionerFactory::PCDPreconditionerFactory(
00064   const ParameterList& params,
00065   const LinearProblem& MpProb,
00066   const LinearProblem& ApProb,
00067   const LinearProblem& FpProb
00068   )
00069   : MpProb_(MpProb),
00070     ApProb_(ApProb),
00071     FpProb_(FpProb),
00072     MpSolver_(),
00073     ApSolver_(),
00074     FSolver_()
00075 {
00076   ParameterList msParams = params.sublist("MpSolver");
00077   MpSolver_ = LinearSolverBuilder::createSolver(msParams);
00078   ParameterList asParams = params.sublist("ApSolver");
00079   ApSolver_ = LinearSolverBuilder::createSolver(asParams);
00080   ParameterList fsParams = params.sublist("FSolver");
00081   FSolver_ = LinearSolverBuilder::createSolver(fsParams);
00082 }
00083 
00084 Preconditioner<double> 
00085 PCDPreconditionerFactory::
00086 createPreconditioner(const LinearOperator<double>& K) const
00087 {
00088   Tabs tab;
00089 
00090   LinearOperator<double> F = K.getBlock(0,0);
00091 //  F.setName("F");
00092   LinearOperator<double> FInv = inverse(F, FSolver_);
00093 //  FInv.setName("FInv");
00094   LinearOperator<double> Bt = K.getBlock(0,1);
00095 //  Bt.setName("Bt");
00096 
00097 
00098   LinearOperator<double> Fp = FpProb_.getOperator();
00099 
00100   LinearOperator<double> Mp = MpProb_.getOperator();
00101 //  Mp.setName("Mp");
00102 
00103   LinearOperator<double> MpInv = inverse(Mp, MpSolver_);
00104 //  MpInv.setName("MpInv");
00105 
00106   LinearOperator<double> Ap = ApProb_.getOperator();
00107 //  Ap.setName("Ap");
00108 
00109   LinearOperator<double> ApInv = inverse(Ap, ApSolver_);
00110 //  ApInv.setName("ApInv");
00111 
00112 
00113   VectorSpace<double> pDomain = Bt.domain();
00114   VectorSpace<double> uDomain = F.domain();
00115 
00116   LinearOperator<double> Iu = identityOperator(uDomain);
00117 //  Iu.setName("Iu");
00118   LinearOperator<double> Ip = identityOperator(pDomain);
00119 //  Ip.setName("Ip");
00120 
00121   LinearOperator<double> XInv = MpInv * Fp * ApInv;
00122 
00123   VectorSpace<double> rowSpace = K.range();
00124   VectorSpace<double> colSpace = K.domain();
00125    
00126   LinearOperator<double> Q1 = makeBlockOperator(colSpace, rowSpace);
00127 //  Q1.setName("Q1");
00128   LinearOperator<double> Q2 = makeBlockOperator(colSpace, rowSpace);
00129   // Q2.setName("Q2");
00130   LinearOperator<double> Q3 = makeBlockOperator(colSpace, rowSpace);
00131   //Q3.setName("Q3");
00132    
00133   Q1.setBlock(0, 0, FInv);
00134   Q1.setBlock(1, 1, Ip);
00135   Q1.endBlockFill();
00136    
00137   Q2.setBlock(0, 0, Iu);
00138   Q2.setBlock(0, 1, -1.0*Bt);
00139   Q2.setBlock(1, 1, Ip);
00140   Q2.endBlockFill();
00141    
00142   Q3.setBlock(0, 0, Iu);
00143   Q3.setBlock(1, 1, -1.0*XInv);
00144   Q3.endBlockFill();
00145    
00146   LinearOperator<double> P1 = Q2 * Q3;
00147   LinearOperator<double> PInv = Q1 * P1;
00148 
00149   return new GenericRightPreconditioner<double>(PInv);
00150 }
00151 
00152 

Site Contact