MueLu Version of the Day
Loading...
Searching...
No Matches
MueLu_IntrepidPCoarsenFactory_decl.hpp
Go to the documentation of this file.
1// @HEADER
2//
3// ***********************************************************************
4//
5// MueLu: A package for multigrid based preconditioning
6// Copyright 2012 Sandia Corporation
7//
8// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
9// the U.S. Government retains certain rights in this software.
10//
11// Redistribution and use in source and binary forms, with or without
12// modification, are permitted provided that the following conditions are
13// met:
14//
15// 1. Redistributions of source code must retain the above copyright
16// notice, this list of conditions and the following disclaimer.
17//
18// 2. Redistributions in binary form must reproduce the above copyright
19// notice, this list of conditions and the following disclaimer in the
20// documentation and/or other materials provided with the distribution.
21//
22// 3. Neither the name of the Corporation nor the names of the
23// contributors may be used to endorse or promote products derived from
24// this software without specific prior written permission.
25//
26// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37//
38// Questions? Contact
39// Jonathan Hu (jhu@sandia.gov)
40// Andrey Prokopenko (aprokop@sandia.gov)
41// Ray Tuminaro (rstumin@sandia.gov)
42//
43// ***********************************************************************
44//
45// @HEADER
46#ifndef MUELU_IPCFACTORY_DECL_HPP
47#define MUELU_IPCFACTORY_DECL_HPP
48
49#include <string>
50#include <vector>
51
52#include "MueLu_ConfigDefs.hpp"
54
55#include "MueLu_Level_fwd.hpp"
58#include "MueLu_PFactory.hpp"
62
63#include "Intrepid2_Basis.hpp"
64
65#include "Kokkos_DynRankView.hpp"
66
67#include <Xpetra_Import.hpp>
68
69namespace MueLu {
70
111template <class Scalar = DefaultScalar,
114 class Node = DefaultNode>
116#undef MUELU_INTREPIDPCOARSENFACTORY_SHORT
118
119 public:
120 typedef Kokkos::DynRankView<LocalOrdinal,typename Node::device_type> LOFieldContainer;
121 typedef Kokkos::DynRankView<double,typename Node::device_type> SCFieldContainer;
122 typedef Intrepid2::Basis<typename Node::device_type::execution_space,double,double> Basis; // Hardwired on purpose
123
125
126
131
134
135 RCP<const ParameterList> GetValidParameterList() const;
136
138
140
141
142 void DeclareInput(Level &fineLevel, Level &coarseLevel) const;
143
145
147
148
154 void Build(Level& fineLevel, Level &coarseLevel) const;
155
156 void BuildP(Level &fineLevel, Level &coarseLevel) const; //Build()
157
159 private:
161
162 // NOTE: This is hardwired to double on purpose.
164 const std::vector<bool> & hi_nodeIsOwned,
165 const SCFieldContainer & hi_DofCoords,
166 const std::vector<size_t> &lo_node_in_hi,
167 const Basis &lo_Basis,
168 const std::vector<LocalOrdinal> & hi_to_lo_map,
169 const Teuchos::RCP<const Map> & lo_colMap,
170 const Teuchos::RCP<const Map> & lo_domainMap,
171 const Teuchos::RCP<const Map> & hi_map,
172 Teuchos::RCP<Matrix>& P) const;
174
175 // NOTE: This is hardwired to double on purpose.
177 const std::vector<bool> & hi_nodeIsOwned,
178 const SCFieldContainer & hi_DofCoords,
179 const LOFieldContainer & lo_elemToHiRepresentativeNode,
180 const Basis &lo_basis,
181 const std::vector<LocalOrdinal> & hi_to_lo_map,
182 const Teuchos::RCP<const Map> & lo_colMap,
183 const Teuchos::RCP<const Map> & lo_domainMap,
184 const Teuchos::RCP<const Map> & hi_map,
185 Teuchos::RCP<Matrix>& P) const;
186
187
188 }; //class IntrepidPCoarsenFactory
189
190
191 /* Utility functions for use with Intrepid */
192 namespace MueLuIntrepid {
193
194 template<class Scalar,class KokkosExecutionSpace>
195 Teuchos::RCP<Intrepid2::Basis<KokkosExecutionSpace,Scalar,Scalar> > BasisFactory(const std::string & name, int & degree);
196
197 template<class Scalar,class KokkosDeviceType>
198 void IntrepidGetLoNodeInHi(const Teuchos::RCP<Intrepid2::Basis<typename KokkosDeviceType::execution_space,Scalar,Scalar> > &hi_basis,
199 const Teuchos::RCP<Intrepid2::Basis<typename KokkosDeviceType::execution_space,Scalar,Scalar> > &lo_basis,
200 std::vector<size_t> & lo_node_in_hi,
201 Kokkos::DynRankView<Scalar,KokkosDeviceType> & hi_DofCoords);
202
203 template<class LocalOrdinal, class GlobalOrdinal, class Node, class LOFieldContainer>
204 void GenerateLoNodeInHiViaGIDs(const std::vector<std::vector<size_t> > & candidates,const LOFieldContainer & hi_elemToNode,
205 RCP<const Xpetra::Map<LocalOrdinal,GlobalOrdinal,Node> > & hi_columnMap,
206 LOFieldContainer & lo_elemToHiRepresentativeNode);
207
208 template <class LocalOrdinal, class LOFieldContainer>
209 void BuildLoElemToNode(const LOFieldContainer & hi_elemToNode,
210 const std::vector<bool> & hi_nodeIsOwned,
211 const std::vector<size_t> & lo_node_in_hi,
212 const Teuchos::ArrayRCP<const int> & hi_isDirichlet,
213 LOFieldContainer & lo_elemToNode,
214 std::vector<bool> & lo_nodeIsOwned,
215 std::vector<LocalOrdinal> & hi_to_lo_map,
216 int & lo_numOwnedNodes);
217
218 template <class LocalOrdinal, class LOFieldContainer>
219 void BuildLoElemToNodeViaRepresentatives(const LOFieldContainer & hi_elemToNode,
220 const std::vector<bool> & hi_nodeIsOwned,
221 const LOFieldContainer & lo_elemToHiRepresentativeNode,
222 LOFieldContainer & lo_elemToNode,
223 std::vector<bool> & lo_nodeIsOwned,
224 std::vector<LocalOrdinal> & hi_to_lo_map,
225 int & lo_numOwnedNodes);
226
227
228 template <class LocalOrdinal, class GlobalOrdinal, class Node>
229 void GenerateColMapFromImport(const Xpetra::Import<LocalOrdinal,GlobalOrdinal,Node> & hi_importer,const std::vector<LocalOrdinal> &hi_to_lo_map,const Xpetra::Map<LocalOrdinal,GlobalOrdinal,Node> & lo_domainMap, const size_t & lo_columnMapLength, RCP<const Xpetra::Map<LocalOrdinal,GlobalOrdinal,Node> > & lo_columnMap);
230
231
232 template<class Basis, class SCFieldContainer>
233 void GenerateRepresentativeBasisNodes(const Basis & basis, const SCFieldContainer & ReferenceNodeLocations, const double threshold, std::vector<std::vector<size_t> > & representative_node_candidates);
234
235 // ! Given an element to (global) node map and a basis, determine one global ordinal per geometric entity (vertex, edge, face,
236 // ! interior). On exit, seeds container is of dimension (spaceDim+1), and contains a sorted vector of local ordinals
237 // ! belonging to entities of that dimension. Only locally-owned degrees of freedom (as determined by rowMap and columnMap)
238 // ! will be stored in seeds.
239 template<class Basis, class LOFieldContainer, class LocalOrdinal, class GlobalOrdinal, class Node>
240 void FindGeometricSeedOrdinals(Teuchos::RCP<Basis> basis, const LOFieldContainer &elementToNodeMap,
241 std::vector<std::vector<LocalOrdinal> > &seeds,
242 const Xpetra::Map<LocalOrdinal,GlobalOrdinal,Node> &rowMap,
243 const Xpetra::Map<LocalOrdinal,GlobalOrdinal,Node> &columnMap);
244
245 }//namespace MueLuIntrepid
246} //namespace MueLu
247
248#define MUELU_INTREPIDPCOARSENFACTORY_SHORT
249#endif // MUELU_INTREPIDPCOARSENFACTORY_DECL_HPP
MueLu::DefaultLocalOrdinal LocalOrdinal
MueLu::DefaultScalar Scalar
MueLu::DefaultGlobalOrdinal GlobalOrdinal
MueLu::DefaultNode Node
Factory for building transfer operators based on coarsening in polynomial degree, following the Intre...
RCP< const ParameterList > GetValidParameterList() const
Return a const parameter list of valid parameters that setParameterList() will accept.
Kokkos::DynRankView< LocalOrdinal, typename Node::device_type > LOFieldContainer
void GenerateLinearCoarsening_pn_kirby_to_p1(const LOFieldContainer &hi_elemToNode, const std::vector< bool > &hi_nodeIsOwned, const SCFieldContainer &hi_DofCoords, const std::vector< size_t > &lo_node_in_hi, const Basis &lo_Basis, const std::vector< LocalOrdinal > &hi_to_lo_map, const Teuchos::RCP< const Map > &lo_colMap, const Teuchos::RCP< const Map > &lo_domainMap, const Teuchos::RCP< const Map > &hi_map, Teuchos::RCP< Matrix > &P) const
Kokkos::DynRankView< double, typename Node::device_type > SCFieldContainer
IntrepidPCoarsenFactory()
Constructor. User can supply a factory for generating the tentative prolongator.
void BuildP(Level &fineLevel, Level &coarseLevel) const
Abstract Build method.
Intrepid2::Basis< typename Node::device_type::execution_space, double, double > Basis
void Build(Level &fineLevel, Level &coarseLevel) const
Build method.
void DeclareInput(Level &fineLevel, Level &coarseLevel) const
Input.
void GenerateLinearCoarsening_pn_kirby_to_pm(const LOFieldContainer &hi_elemToNode, const std::vector< bool > &hi_nodeIsOwned, const SCFieldContainer &hi_DofCoords, const LOFieldContainer &lo_elemToHiRepresentativeNode, const Basis &lo_basis, const std::vector< LocalOrdinal > &hi_to_lo_map, const Teuchos::RCP< const Map > &lo_colMap, const Teuchos::RCP< const Map > &lo_domainMap, const Teuchos::RCP< const Map > &hi_map, Teuchos::RCP< Matrix > &P) const
Class that holds all level-specific information.
Factory that provides an interface for a concrete implementation of a prolongation operator.
void FindGeometricSeedOrdinals(Teuchos::RCP< Basis > basis, const LOFieldContainer &elementToNodeMap, std::vector< std::vector< LocalOrdinal > > &seeds, const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > &rowMap, const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > &columnMap)
void IntrepidGetLoNodeInHi(const Teuchos::RCP< Intrepid2::Basis< typename KokkosDeviceType::execution_space, Scalar, Scalar > > &hi_basis, const Teuchos::RCP< Intrepid2::Basis< typename KokkosDeviceType::execution_space, Scalar, Scalar > > &lo_basis, std::vector< size_t > &lo_node_in_hi, Kokkos::DynRankView< Scalar, KokkosDeviceType > &hi_DofCoords)
void GenerateRepresentativeBasisNodes(const Basis &basis, const SCFieldContainer &ReferenceNodeLocations, const double threshold, std::vector< std::vector< size_t > > &representative_node_candidates)
void GenerateColMapFromImport(const Xpetra::Import< LocalOrdinal, GlobalOrdinal, Node > &hi_importer, const std::vector< LocalOrdinal > &hi_to_lo_map, const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > &lo_domainMap, const size_t &lo_columnMapLength, RCP< const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > &lo_columnMap)
void BuildLoElemToNodeViaRepresentatives(const LOFieldContainer &hi_elemToNode, const std::vector< bool > &hi_nodeIsOwned, const LOFieldContainer &lo_elemToHiRepresentativeNode, LOFieldContainer &lo_elemToNode, std::vector< bool > &lo_nodeIsOwned, std::vector< LocalOrdinal > &hi_to_lo_map, int &lo_numOwnedNodes)
void BuildLoElemToNode(const LOFieldContainer &hi_elemToNode, const std::vector< bool > &hi_nodeIsOwned, const std::vector< size_t > &lo_node_in_hi, const Teuchos::ArrayRCP< const int > &hi_isDirichlet, LOFieldContainer &lo_elemToNode, std::vector< bool > &lo_nodeIsOwned, std::vector< LocalOrdinal > &hi_to_lo_map, int &lo_numOwnedNodes)
void GenerateLoNodeInHiViaGIDs(const std::vector< std::vector< size_t > > &candidates, const LOFieldContainer &hi_elemToNode, RCP< const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > &hi_columnMap, LOFieldContainer &lo_elemToHiRepresentativeNode)
Teuchos::RCP< Intrepid2::Basis< KokkosExecutionSpace, Scalar, Scalar > > BasisFactory(const std::string &name, int &degree)
Namespace for MueLu classes and methods.
KokkosClassic::DefaultNode::DefaultNodeType DefaultNode
Tpetra::Details::DefaultTypes::scalar_type DefaultScalar