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 namespace Nektar
41 {
42 
45  "CellHistoryPoints", FilterCellHistoryPoints::create);
46 
47 /**
48  *
49  */
52  const ParamMap &pParams) :
53  FilterHistoryPoints(pSession, pParams)
54 {
55 }
56 
57 
58 /**
59  *
60  */
62 {
63 
64 }
65 
66 
67 /**
68  *
69  */
72  const NekDouble &time)
73 {
74  // Only output every m_outputFrequency.
75  if ((m_index++) % m_outputFrequency)
76  {
77  return;
78  }
79 
80  int j = 0;
81  int k = 0;
82  int numPoints = m_historyPoints.size();
83  int numFields = m_cell->GetNumCellVariables();
84  LibUtilities::CommSharedPtr vComm = pFields[0]->GetComm();
85  Array<OneD, NekDouble> data(numPoints*numFields, 0.0);
86  Array<OneD, NekDouble> gloCoord(3, 0.0);
87  std::list<std::pair<SpatialDomains::PointGeomSharedPtr,
89 
90  Array<OneD, NekDouble> physvals;
91  Array<OneD, NekDouble> locCoord;
92  int expId;
93  int nppp = 0; // Number of points per plane
94 
95  // Pull out data values field by field
96  for (j = 0; j < numFields; ++j)
97  {
99  {
100  for (k = 0, x = m_historyList.begin(); x != m_historyList.end();
101  ++x, ++k)
102  {
103  locCoord = (*x).second;
104  expId = (*x).first->GetVid();
105  nppp = pFields[0]->GetPlane(0)->GetTotPoints();
106 
107  physvals = m_cell->GetCellSolution(j) + m_outputPlane*nppp
108  + pFields[j]->GetPhys_Offset(expId);
109 
110  // interpolate point can do with zero plane methods
111  data[m_historyLocalPointMap[k]*numFields+j]
112  = pFields[0]->GetExp(expId)->StdPhysEvaluate(
113  locCoord,physvals);
114 
115  }
116  }
117  else
118  {
119  for (k = 0, x = m_historyList.begin();
120  x != m_historyList.end();
121  ++x, ++k)
122  {
123  locCoord = (*x).second;
124  expId = (*x).first->GetVid();
125 
126  physvals = m_cell->GetCellSolution(j)
127  + pFields[0]->GetPhys_Offset(expId);
128 
129  // interpolate point
130  data[m_historyLocalPointMap[k]*numFields+j]
131  = pFields[0]->GetExp(expId)->StdPhysEvaluate(
132  locCoord,physvals);
133  }
134  }
135  }
136 
137  // Exchange history data
138  // This could be improved to reduce communication but works for now
139  vComm->AllReduce(data, LibUtilities::ReduceSum);
140 
141  // Only the root process writes out history data
142  if (vComm->GetRank() == 0)
143  {
144 
145  // Write data values point by point
146  for (k = 0; k < m_historyPoints.size(); ++k)
147  {
148  m_outputStream.width(8);
149  m_outputStream << setprecision(6) << time;
150  for (int j = 0; j < numFields; ++j)
151  {
152  m_outputStream.width(25);
153  m_outputStream << setprecision(16) << data[k*numFields+j];
154  }
155  m_outputStream << endl;
156  }
157  }
158 }
159 
160 }
FilterCellHistoryPoints(const LibUtilities::SessionReaderSharedPtr &pSession, const ParamMap &pParams)
virtual void v_Update(const Array< OneD, const MultiRegions::ExpListSharedPtr > &pFields, const NekDouble &time)
boost::shared_ptr< SessionReader > SessionReaderSharedPtr
Definition: MeshPartition.h:51
static std::string className
Name of the class.
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
static SolverUtils::FilterSharedPtr create(const LibUtilities::SessionReaderSharedPtr &pSession, const ParamMap &pParams)
Creates an instance of this class.
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