Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef TSFBCPARTITIONEDVSBUILDER_HPP
00028 #define TSFBCPARTITIONEDVSBUILDER_HPP
00029
00030 #include "TSFVectorSpaceImpl.hpp"
00031 #include "TSFVectorType.hpp"
00032 #include "Teuchos_Array.hpp"
00033 #include "TSFProductVectorSpaceImpl.hpp"
00034
00035 namespace TSFExtended
00036 {
00037 using namespace Teuchos;
00038
00039
00040
00041
00042
00043 template <class Scalar>
00044 VectorSpace<Scalar> buildPartitionedSpace(
00045 int nTotalDofs,
00046 int lowestLocalDof,
00047 int nLocalDofs,
00048 const Array<int>& isBCIndex,
00049 const VectorType<Scalar>& internalType,
00050 const VectorType<Scalar>& bcType,
00051 const MPIComm& comm
00052 )
00053 {
00054 int nBCDofs = 0;
00055 for (int i=0; i<nLocalDofs; i++)
00056 {
00057 if (isBCIndex[i]) nBCDofs++;
00058 }
00059
00060
00061 int nTotalBCDofs = nBCDofs;
00062 comm.allReduce(&nBCDofs, &nTotalBCDofs, 1, MPIComm::INT, MPIComm::SUM);
00063 int nTotalInteriorDofs = nTotalDofs - nTotalBCDofs;
00064
00065
00066 Array<int> interiorDofs(nLocalDofs - nBCDofs);
00067 Array<int> bcDofs(nBCDofs);
00068 int iBC = 0;
00069 int iIn = 0;
00070
00071 for (int i=0; i<nLocalDofs; i++)
00072 {
00073 if (isBCIndex[i]) bcDofs[iBC++] = lowestLocalDof+i;
00074 else interiorDofs[iIn++] = lowestLocalDof+i;
00075 }
00076
00077 int p = MPIComm::world().getRank();
00078
00079
00080 VectorSpace<double> bcSpace = bcType.createSpace(nTotalBCDofs, nBCDofs,
00081 &(bcDofs[0]), comm);
00082 VectorSpace<double> interiorSpace = internalType.createSpace(nTotalInteriorDofs, nLocalDofs-nBCDofs,
00083 &(interiorDofs[0]), comm);
00084
00085 return productSpace<double>(interiorSpace, bcSpace);
00086 }
00087
00088 }
00089
00090
00091 #endif