1 // @HEADER
2 // ************************************************************************
3 //
4 //               Rapid Optimization Library (ROL) Package
5 //                 Copyright (2014) Sandia Corporation
6 //
7 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8 // license for use of this work by or on behalf of the U.S. Government.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Questions? Contact lead developers:
38 //              Drew Kouri   (dpkouri@sandia.gov) and
39 //              Denis Ridzal (dridzal@sandia.gov)
40 //
41 // ************************************************************************
42 // @HEADER
43 
44 #include "../../TOOLS/meshmanager.hpp"
45 
46 template <class Real>
47 class MeshManager_adv_diff : public MeshManager_Rectangle<Real> {
48 
49 private:
50 
51   int nx_;
52   int ny_;
53   ROL::Ptr<std::vector<std::vector<std::vector<int>>>>  meshSideSets_;
54 
55 public:
56 
MeshManager_adv_diff(Teuchos::ParameterList & parlist)57   MeshManager_adv_diff(Teuchos::ParameterList &parlist) : MeshManager_Rectangle<Real>(parlist)
58   {
59     nx_ = parlist.sublist("Geometry").get("NX", 3);
60     ny_ = parlist.sublist("Geometry").get("NY", 3);
61     computeSideSets();
62   }
63 
64 
computeSideSets()65   void computeSideSets() {
66 
67     int numSideSets = 2;
68     meshSideSets_ = ROL::makePtr<std::vector<std::vector<std::vector<int>>>>(numSideSets);
69 
70     // Dirichlet
71     (*meshSideSets_)[0].resize(4);
72     (*meshSideSets_)[0][0].resize(nx_);
73     (*meshSideSets_)[0][1].resize(0);
74     (*meshSideSets_)[0][2].resize(nx_);
75     (*meshSideSets_)[0][3].resize(ny_);
76     // Neumann
77     (*meshSideSets_)[1].resize(4);
78     (*meshSideSets_)[1][0].resize(0);
79     (*meshSideSets_)[1][1].resize(ny_);
80     (*meshSideSets_)[1][2].resize(0);
81     (*meshSideSets_)[1][3].resize(0);
82 
83     for (int i=0; i<nx_; ++i) {
84       (*meshSideSets_)[0][0][i] = i;
85     }
86     for (int i=0; i<ny_; ++i) {
87       (*meshSideSets_)[1][1][i] = (i+1)*nx_-1;
88     }
89     for (int i=0; i<nx_; ++i) {
90       (*meshSideSets_)[0][2][i] = i + nx_*(ny_-1);
91     }
92     for (int i=0; i<ny_; ++i) {
93       (*meshSideSets_)[0][3][i] = i*nx_;
94     }
95 
96   } // computeSideSets
97 
getSideSets(const bool verbose=false,std::ostream & outStream=std::cout) const98   ROL::Ptr<std::vector<std::vector<std::vector<int>>>> getSideSets(
99               const bool verbose = false,
100               std::ostream & outStream = std::cout) const {
101     if (verbose) {
102       outStream << "Mesh_stoch_adv_diff: getSideSets called" << std::endl;
103       outStream << "Mesh_stoch_adv_diff: numSideSets = "     << meshSideSets_->size() << std::endl;
104     }
105     return meshSideSets_;
106   }
107 
108 }; // MeshManager_stoch_adv_diff
109