ContField3D.h 9.63 KB
Newer Older
Sophia Han's avatar
Sophia Han committed
1 2
///////////////////////////////////////////////////////////////////////////////
//
3
// File ContField3D.h
Sophia Han's avatar
Sophia Han committed
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
//
// For more information, please see: http://www.nektar.info
//
// The MIT License
//
// Copyright (c) 2006 Division of Applied Mathematics, Brown University (USA),
// Department of Aeronautics, Imperial College London (UK), and Scientific
// Computing and Imaging Institute, University of Utah (USA).
//
// License for the specific language governing rights and limitations under
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// Description: Field definition in three-dimensions
//
///////////////////////////////////////////////////////////////////////////////

#ifndef NEKTAR_LIBS_MULTIREGIONS_CONTFIELD3D_H
#define NEKTAR_LIBS_MULTIREGIONS_CONTFIELD3D_H
38

39
#include <MultiRegions/MultiRegionsDeclspec.h>
Sophia Han's avatar
Sophia Han committed
40
#include <MultiRegions/MultiRegions.hpp>
41
#include <MultiRegions/DisContField3D.h>
Sophia Han's avatar
Sophia Han committed
42
#include <MultiRegions/GlobalLinSys.h>
43 44 45
#include <MultiRegions/GlobalMatrix.h>
#include <MultiRegions/AssemblyMap/AssemblyMapCG.h>
#include <MultiRegions/AssemblyMap/AssemblyMapDG.h>
Sophia Han's avatar
Sophia Han committed
46 47 48 49 50

namespace Nektar
{
    namespace MultiRegions
    {
51
        class ContField3D: public DisContField3D
Sophia Han's avatar
Sophia Han committed
52 53
        {
        public:
54
            MULTI_REGIONS_EXPORT ContField3D();
55

56
            /// Construct a global continuous field.
57
            MULTI_REGIONS_EXPORT ContField3D(
Chris Cantwell's avatar
Chris Cantwell committed
58 59
                        const LibUtilities::SessionReaderSharedPtr &pSession,
                        const SpatialDomains::MeshGraphSharedPtr &graph3D,
60
                        const std::string &variable  = "DefaultVar",
61 62 63
                        const bool CheckIfSingularSystem = false,
                        const Collections::ImplementationType ImpType
                        = Collections::eNoImpType);
64 65 66 67 68

            /// Construct a global continuous field with solution type based on
            /// another field but using a separate input mesh and boundary
            /// conditions.
            MULTI_REGIONS_EXPORT ContField3D(const ContField3D &In,
Chris Cantwell's avatar
Chris Cantwell committed
69
                        const SpatialDomains::MeshGraphSharedPtr &graph3D,
70 71
                        const std::string &variable,
                        const bool CheckIfSingularSystem = false);
Sophia Han's avatar
Sophia Han committed
72

73
            MULTI_REGIONS_EXPORT ContField3D(const ContField3D &In);
Sophia Han's avatar
Sophia Han committed
74

75
            MULTI_REGIONS_EXPORT virtual ~ContField3D();
Sophia Han's avatar
Sophia Han committed
76

77
            inline const Array<OneD,const MultiRegions::ExpListSharedPtr>& GetBndCondExpansions()
78 79 80
            {
                return m_bndCondExpansions;
            }
81

82
            /// This function return the boundary conditions expansion.
83
            inline const Array<OneD,const MultiRegions::ExpListSharedPtr>
84 85
                    &GetBndCondExp();

86
            MULTI_REGIONS_EXPORT void GenerateDirBndCondForcing(
87 88 89
                    const GlobalLinSysKey &key,
                    Array<OneD, NekDouble> &inout,
                    Array<OneD, NekDouble> &outarray);
90

91 92 93 94 95 96
            inline void Assemble();

            inline void Assemble(
                    const Array<OneD, const NekDouble> &inarray,
                          Array<OneD,NekDouble> &outarray);

97
            inline const AssemblyMapCGSharedPtr& GetLocalToGlobalMap()
98
                                                                        const;
99

100
            MULTI_REGIONS_EXPORT int GetGlobalMatrixNnz(const GlobalMatrixKey &gkey);
Sophia Han's avatar
Sophia Han committed
101

102

Sophia Han's avatar
Sophia Han committed
103
        protected:
104
            AssemblyMapCGSharedPtr m_locToGloMap;
105 106 107 108 109 110 111 112 113

            /// (A shared pointer to) a list which collects all the global
            /// matrices being assembled, such that they should be constructed
            /// only once.
            GlobalMatrixMapShPtr            m_globalMat;

            /// (A shared pointer to) a list which collects all the global
            /// linear system being assembled, such that they should be
            /// constructed only once.
114
            LibUtilities::NekManager<GlobalLinSysKey, GlobalLinSys> m_globalLinSysManager;
Sophia Han's avatar
Sophia Han committed
115

116 117 118
            /// Performs the backward transformation of the spectral/hp
            /// element expansion.
            virtual void v_BwdTrans(
119
                    const Array<OneD, const NekDouble> &inarray,
120 121
                    Array<OneD,       NekDouble> &outarray,
                    CoeffState coeffstate = eLocal);
122 123 124 125 126

            /// Calculates the inner product of a function
            /// \f$f(\boldsymbol{x})\f$ with respect to all <em>global</em>
            /// expansion modes \f$\phi_n^e(\boldsymbol{x})\f$.
            virtual void v_IProductWRTBase(
127
                    const Array<OneD, const NekDouble> &inarray,
128 129
                    Array<OneD,       NekDouble> &outarray,
                    CoeffState coeffstate = eLocal);
130

131 132
            virtual void v_FwdTrans(
                    const Array<OneD, const NekDouble> &inarray,
133 134
                    Array<OneD,       NekDouble> &outarray,
                    CoeffState coeffstate);
135

136
            
Sophia Han's avatar
Sophia Han committed
137 138 139
        private:
            GlobalLinSysSharedPtr GetGlobalLinSys(const GlobalLinSysKey &mkey);

140 141
            GlobalLinSysSharedPtr GenGlobalLinSys(const GlobalLinSysKey &mkey);

142 143 144 145
            /// Returns the global matrix specified by \a mkey.
            GlobalMatrixSharedPtr GetGlobalMatrix(const GlobalMatrixKey &mkey);


146
            void GlobalSolve(const GlobalLinSysKey &key,
147 148 149 150
                    const Array<OneD, const NekDouble> &rhs,
                          Array<OneD,       NekDouble> &inout,
                    const Array<OneD, const NekDouble> &dirForcing
                                                     = NullNekDouble1DArray);
151

152 153 154
            /// Impose the Dirichlet Boundary Conditions on outarray 
            virtual void v_ImposeDirichletConditions(Array<OneD,NekDouble>& outarray);

155 156
            virtual void v_FillBndCondFromField();

157 158 159
            virtual void v_FillBndCondFromField(const int nreg);

            virtual void v_LocalToGlobal(bool useComm);
160 161


162 163
            virtual void v_LocalToGlobal(
                const Array<OneD, const NekDouble> &inarray,
164 165
                Array<OneD,NekDouble> &outarray,
                bool useComm);
166 167


168 169
            virtual void v_GlobalToLocal(void);

170

171 172 173 174 175
            virtual void v_GlobalToLocal(
                const Array<OneD, const NekDouble> &inarray,
                Array<OneD,NekDouble> &outarray);


176 177 178
            virtual void v_MultiplyByInvMassMatrix(
                    const Array<OneD, const NekDouble> &inarray,
                          Array<OneD,       NekDouble> &outarray,
179
                    CoeffState coeffstate);
180

181 182 183
            virtual void v_HelmSolve(
                    const Array<OneD, const NekDouble> &inarray,
                          Array<OneD,       NekDouble> &outarray,
184 185 186
                    const FlagList &flags,
                    const StdRegions::ConstFactorMap &factors,
                    const StdRegions::VarCoeffMap &varcoeff,
187
                    const MultiRegions::VarFactorsMap &varfactors,
188
                    const Array<OneD, const NekDouble> &dirForcing,
189
                    const bool PhysSpaceForcing);
190
            virtual void v_GeneralMatrixOp(
191 192
                    const GlobalMatrixKey             &gkey,
                    const Array<OneD,const NekDouble> &inarray,
193 194
                    Array<OneD,      NekDouble> &outarray,
                    CoeffState coeffstate);
195 196 197

            // Solve the linear advection problem assuming that m_coeffs
            // vector contains an intial estimate for solution
198 199
            MULTI_REGIONS_EXPORT virtual void v_LinearAdvectionDiffusionReactionSolve(
                    const Array<OneD, Array<OneD, NekDouble> > &velocity,
200 201 202 203
                    const Array<OneD, const NekDouble> &inarray,
                    Array<OneD, NekDouble> &outarray,
                    const NekDouble lambda,
                    CoeffState coeffstate = eLocal,
204
                    const Array<OneD, const NekDouble> &dirForcing = NullNekDouble1DArray);
205 206
            
            virtual void v_ClearGlobalLinSysManager(void);
207

Sophia Han's avatar
Sophia Han committed
208
        };
209
        typedef std::shared_ptr<ContField3D>      ContField3DSharedPtr;
210

211
        inline const Array<OneD,const MultiRegions::ExpListSharedPtr>
212 213 214 215 216
                &ContField3D::GetBndCondExp()
        {
            return m_bndCondExpansions;
        }

217

218 219
        inline void ContField3D::Assemble()
        {
220
            m_locToGloMap->Assemble(m_coeffs, m_coeffs);
221 222 223 224 225 226 227 228 229
        }

        inline void ContField3D::Assemble(
                const Array<OneD, const NekDouble> &inarray,
                Array<OneD,NekDouble> &outarray)
        {
            m_locToGloMap->Assemble(inarray, outarray);
        }

230
        inline const AssemblyMapCGSharedPtr&
231 232 233 234
                ContField3D::GetLocalToGlobalMap() const
        {
            return  m_locToGloMap;
        }
235

236

Sophia Han's avatar
Sophia Han committed
237 238 239 240
    } //end of namespace
} //end of namespace

#endif // MULTIERGIONS_CONTFIELD3D_H