Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FilterCellHistoryPoints.cpp
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // File FilterCellHistoryPoints.cpp
4 //
5 // For more information, please see: http://www.nektar.info
6 //
7 // The MIT License
8 //
9 // Copyright (c) 2006 Division of Applied Mathematics, Brown University (USA),
10 // Department of Aeronautics, Imperial College London (UK), and Scientific
11 // Computing and Imaging Institute, University of Utah (USA).
12 //
13 // License for the specific language governing rights and limitations under
14 // Permission is hereby granted, free of charge, to any person obtaining a
15 // copy of this software and associated documentation files (the "Software"),
16 // to deal in the Software without restriction, including without limitation
17 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
18 // and/or sell copies of the Software, and to permit persons to whom the
19 // Software is furnished to do so, subject to the following conditions:
20 //
21 // The above copyright notice and this permission notice shall be included
22 // in all copies or substantial portions of the Software.
23 //
24 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
25 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
27 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
29 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
30 // DEALINGS IN THE SOFTWARE.
31 //
32 // Description: Outputs values at specific points during time-stepping.
33 //
34 ///////////////////////////////////////////////////////////////////////////////
35 
37 #include <iomanip>
39 
40 using namespace std;
41 
42 namespace Nektar
43 {
44 
45 std::string FilterCellHistoryPoints::className
47  "CellHistoryPoints", FilterCellHistoryPoints::create);
48 
49 /**
50  *
51  */
52 FilterCellHistoryPoints::FilterCellHistoryPoints(
54  const ParamMap &pParams) :
55  FilterHistoryPoints(pSession, pParams)
56 {
57 }
58 
59 
60 /**
61  *
62  */
64 {
65 
66 }
67 
68 
69 /**
70  *
71  */
74  const NekDouble &time)
75 {
76  // Only output every m_outputFrequency.
77  if ((m_index++) % m_outputFrequency)
78  {
79  return;
80  }
81 
82  int j = 0;
83  int k = 0;
84  int numPoints = m_historyPoints.size();
85  int numFields = m_cell->GetNumCellVariables();
86  LibUtilities::CommSharedPtr vComm = pFields[0]->GetComm();
87  Array<OneD, NekDouble> data(numPoints*numFields, 0.0);
88  Array<OneD, NekDouble> gloCoord(3, 0.0);
89  std::list<std::pair<SpatialDomains::PointGeomSharedPtr,
91 
92  Array<OneD, NekDouble> physvals;
93  Array<OneD, NekDouble> locCoord;
94  int expId;
95  int nppp = 0; // Number of points per plane
96 
97  // Pull out data values field by field
98  for (j = 0; j < numFields; ++j)
99  {
101  {
102  for (k = 0, x = m_historyList.begin(); x != m_historyList.end();
103  ++x, ++k)
104  {
105  locCoord = (*x).second;
106  expId = (*x).first->GetVid();
107  nppp = pFields[0]->GetPlane(0)->GetTotPoints();
108 
109  physvals = m_cell->GetCellSolution(j) + m_outputPlane*nppp
110  + pFields[j]->GetPhys_Offset(expId);
111 
112  // interpolate point can do with zero plane methods
113  data[m_historyLocalPointMap[k]*numFields+j]
114  = pFields[0]->GetExp(expId)->StdPhysEvaluate(
115  locCoord,physvals);
116 
117  }
118  }
119  else
120  {
121  for (k = 0, x = m_historyList.begin();
122  x != m_historyList.end();
123  ++x, ++k)
124  {
125  locCoord = (*x).second;
126  expId = (*x).first->GetVid();
127 
128  physvals = m_cell->GetCellSolution(j)
129  + pFields[0]->GetPhys_Offset(expId);
130 
131  // interpolate point
132  data[m_historyLocalPointMap[k]*numFields+j]
133  = pFields[0]->GetExp(expId)->StdPhysEvaluate(
134  locCoord,physvals);
135  }
136  }
137  }
138 
139  // Exchange history data
140  // This could be improved to reduce communication but works for now
141  vComm->AllReduce(data, LibUtilities::ReduceSum);
142 
143  // Only the root process writes out history data
144  if (vComm->GetRank() == 0)
145  {
146 
147  // Write data values point by point
148  for (k = 0; k < m_historyPoints.size(); ++k)
149  {
150  m_outputStream.width(8);
151  m_outputStream << setprecision(6) << time;
152  for (int j = 0; j < numFields; ++j)
153  {
154  m_outputStream.width(25);
155  m_outputStream << setprecision(16) << data[k*numFields+j];
156  }
157  m_outputStream << endl;
158  }
159  }
160 }
161 
162 }
virtual void v_Update(const Array< OneD, const MultiRegions::ExpListSharedPtr > &pFields, const NekDouble &time)
STL namespace.
boost::shared_ptr< SessionReader > SessionReaderSharedPtr
Definition: MeshPartition.h:51
boost::shared_ptr< Comm > CommSharedPtr
Pointer to a Communicator object.
Definition: Comm.h:53
unsigned int m_outputPlane
plane to take history point from if using a homogeneous1D expansion
SpatialDomains::PointGeomVector m_historyPoints
double NekDouble
std::map< std::string, std::string > ParamMap
Definition: Filter.h:67
StandardMatrixTag boost::call_traits< LhsDataType >::const_reference rhs typedef NekMatrix< LhsDataType, StandardMatrixTag >::iterator iterator
FilterFactory & GetFilterFactory()
Definition: Filter.cpp:42
std::list< std::pair< SpatialDomains::PointGeomSharedPtr, Array< OneD, NekDouble > > > m_historyList
boost::shared_ptr< PointGeom > PointGeomSharedPtr
Definition: Geometry.h:60
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, tDescription pDesc="")
Register a class with the factory.
Definition: NekFactory.hpp:215