ContField3D.h 9.3 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
                        const bool CheckIfSingularSystem = false);
62
63
64
65
66

            /// 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
67
                        const SpatialDomains::MeshGraphSharedPtr &graph3D,
68
69
                        const std::string &variable,
                        const bool CheckIfSingularSystem = false);
Sophia Han's avatar
Sophia Han committed
70

71
            MULTI_REGIONS_EXPORT ContField3D(const ContField3D &In);
Sophia Han's avatar
Sophia Han committed
72

73
            MULTI_REGIONS_EXPORT virtual ~ContField3D();
Sophia Han's avatar
Sophia Han committed
74

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

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

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

89
90
91
92
93
94
            inline void Assemble();

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

95
            inline const AssemblyMapCGSharedPtr& GetLocalToGlobalMap()
96
                                                                        const;
97

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

100

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

            /// (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.
112
            LibUtilities::NekManager<GlobalLinSysKey, GlobalLinSys> m_globalLinSysManager;
Sophia Han's avatar
Sophia Han committed
113

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

            /// 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(
125
                    const Array<OneD, const NekDouble> &inarray,
126
127
                    Array<OneD,       NekDouble> &outarray,
                    CoeffState coeffstate = eLocal);
128

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

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

138
139
            GlobalLinSysSharedPtr GenGlobalLinSys(const GlobalLinSysKey &mkey);

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


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

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

153
154
            virtual void v_FillBndCondFromField();

155
156
157
            virtual void v_LocalToGlobal(void);


158
159
160
161
162
            virtual void v_LocalToGlobal(
                const Array<OneD, const NekDouble> &inarray,
                Array<OneD,NekDouble> &outarray);


163
164
            virtual void v_GlobalToLocal(void);

165

166
167
168
169
170
            virtual void v_GlobalToLocal(
                const Array<OneD, const NekDouble> &inarray,
                Array<OneD,NekDouble> &outarray);


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

176
177
178
            virtual void v_HelmSolve(
                    const Array<OneD, const NekDouble> &inarray,
                          Array<OneD,       NekDouble> &outarray,
179
180
181
                    const FlagList &flags,
                    const StdRegions::ConstFactorMap &factors,
                    const StdRegions::VarCoeffMap &varcoeff,
182
                    const Array<OneD, const NekDouble> &dirForcing);
Sophia Han's avatar
Sophia Han committed
183

184
            virtual void v_GeneralMatrixOp(
185
186
                    const GlobalMatrixKey             &gkey,
                    const Array<OneD,const NekDouble> &inarray,
187
188
                    Array<OneD,      NekDouble> &outarray,
                    CoeffState coeffstate);
189
190
191

            // Solve the linear advection problem assuming that m_coeffs
            // vector contains an intial estimate for solution
192
193
            MULTI_REGIONS_EXPORT virtual void v_LinearAdvectionDiffusionReactionSolve(
                    const Array<OneD, Array<OneD, NekDouble> > &velocity,
194
195
196
197
                    const Array<OneD, const NekDouble> &inarray,
                    Array<OneD, NekDouble> &outarray,
                    const NekDouble lambda,
                    CoeffState coeffstate = eLocal,
198
                    const Array<OneD, const NekDouble> &dirForcing = NullNekDouble1DArray);
199
200
            
            virtual void v_ClearGlobalLinSysManager(void);
201

Sophia Han's avatar
Sophia Han committed
202
203
        };
        typedef boost::shared_ptr<ContField3D>      ContField3DSharedPtr;
204

205
        inline const Array<OneD,const MultiRegions::ExpListSharedPtr>
206
207
208
209
210
211
212
                &ContField3D::GetBndCondExp()
        {
            return m_bndCondExpansions;
        }

        inline void ContField3D::Assemble()
        {
213
            m_locToGloMap->Assemble(m_coeffs, m_coeffs);
214
215
216
217
218
219
220
221
222
        }

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

223
        inline const AssemblyMapCGSharedPtr&
224
225
226
227
                ContField3D::GetLocalToGlobalMap() const
        {
            return  m_locToGloMap;
        }
228

229

Sophia Han's avatar
Sophia Han committed
230
231
232
233
    } //end of namespace
} //end of namespace

#endif // MULTIERGIONS_CONTFIELD3D_H