Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
Nektar::Utilities::ProcessC0Projection Class Reference

This processing module calculates the Q Criterion and adds it as an extra-field to the output file. More...

#include <ProcessC0Projection.h>

Inheritance diagram for Nektar::Utilities::ProcessC0Projection:
Inheritance graph
[legend]
Collaboration diagram for Nektar::Utilities::ProcessC0Projection:
Collaboration graph
[legend]

Public Member Functions

 ProcessC0Projection (FieldSharedPtr f)
 
virtual ~ProcessC0Projection ()
 
virtual void Process (po::variables_map &vm)
 Write mesh to output file. More...
 
virtual std::string GetModuleName ()
 
- Public Member Functions inherited from Nektar::Utilities::ProcessModule
 ProcessModule ()
 
 ProcessModule (FieldSharedPtr p_f)
 
 ProcessModule (MeshSharedPtr p_m)
 
- Public Member Functions inherited from Nektar::Utilities::Module
 Module (FieldSharedPtr p_f)
 
void RegisterConfig (string key, string value)
 Register a configuration option with a module. More...
 
void PrintConfig ()
 Print out all configuration options for a module. More...
 
void SetDefaults ()
 Sets default configuration options for those which have not been set. More...
 
bool GetRequireEquiSpaced (void)
 
void SetRequireEquiSpaced (bool pVal)
 
void EvaluateTriFieldAtEquiSpacedPts (LocalRegions::ExpansionSharedPtr &exp, const Array< OneD, const NekDouble > &infield, Array< OneD, NekDouble > &outfield)
 
 Module (MeshSharedPtr p_m)
 
virtual void Process ()=0
 
void RegisterConfig (std::string key, std::string value)
 
void PrintConfig ()
 
void SetDefaults ()
 
MeshSharedPtr GetMesh ()
 
virtual void ProcessVertices ()
 Extract element vertices. More...
 
virtual void ProcessEdges (bool ReprocessEdges=true)
 Extract element edges. More...
 
virtual void ProcessFaces (bool ReprocessFaces=true)
 Extract element faces. More...
 
virtual void ProcessElements ()
 Generate element IDs. More...
 
virtual void ProcessComposites ()
 Generate composites. More...
 
virtual void ClearElementLinks ()
 

Static Public Member Functions

static boost::shared_ptr< Modulecreate (FieldSharedPtr f)
 Creates an instance of this class. More...
 

Static Public Attributes

static ModuleKey className
 

Additional Inherited Members

- Protected Member Functions inherited from Nektar::Utilities::Module
 Module ()
 
void ReorderPrisms (PerMap &perFaces)
 Reorder node IDs so that prisms and tetrahedra are aligned correctly. More...
 
void PrismLines (int prism, PerMap &perFaces, std::set< int > &prismsDone, std::vector< ElementSharedPtr > &line)
 
- Protected Attributes inherited from Nektar::Utilities::Module
FieldSharedPtr m_f
 Field object. More...
 
map< string, ConfigOptionm_config
 List of configuration values. More...
 
bool m_requireEquiSpaced
 
MeshSharedPtr m_mesh
 Mesh object. More...
 
std::map< std::string,
ConfigOption
m_config
 List of configuration values. More...
 

Detailed Description

This processing module calculates the Q Criterion and adds it as an extra-field to the output file.

Definition at line 50 of file ProcessC0Projection.h.

Constructor & Destructor Documentation

Nektar::Utilities::ProcessC0Projection::ProcessC0Projection ( FieldSharedPtr  f)

Definition at line 55 of file ProcessC0Projection.cpp.

References Nektar::Utilities::Module::m_config.

55  : ProcessModule(f)
56 {
57  m_config["fields"] = ConfigOption(false,"All","Start field to project");
58  m_config["localtoglobalmap"] = ConfigOption(true,"0","Just perform a local to global mapping and back");
59  m_config["usexmlbcs"] = ConfigOption(true,"0","Use boundary conditions given in xml file. Requires all projected fields to be defined in xml file");
60  m_config["helmsmoothing"] = ConfigOption(false,"Not Set","Use a Helmholtz smoother to remove high frequency components above specified L");
61 
62  f->m_declareExpansionAsContField = true;
63 }
map< string, ConfigOption > m_config
List of configuration values.
Nektar::Utilities::ProcessC0Projection::~ProcessC0Projection ( )
virtual

Definition at line 65 of file ProcessC0Projection.cpp.

66 {
67 }

Member Function Documentation

static boost::shared_ptr<Module> Nektar::Utilities::ProcessC0Projection::create ( FieldSharedPtr  f)
inlinestatic

Creates an instance of this class.

Definition at line 54 of file ProcessC0Projection.h.

References Nektar::MemoryManager< DataType >::AllocateSharedPtr().

55  {
57  }
static boost::shared_ptr< DataType > AllocateSharedPtr()
Allocate a shared pointer from the memory pool.
virtual std::string Nektar::Utilities::ProcessC0Projection::GetModuleName ( )
inlinevirtual

Implements Nektar::Utilities::Module.

Definition at line 66 of file ProcessC0Projection.h.

67  {
68  return "ProcessC0Projection";
69  }
void Nektar::Utilities::ProcessC0Projection::Process ( po::variables_map &  vm)
virtual

Write mesh to output file.

Implements Nektar::Utilities::Module.

Definition at line 69 of file ProcessC0Projection.cpp.

References ASSERTL0, Nektar::StdRegions::eFactorLambda, Nektar::ParseUtils::GenerateOrderedVector(), Nektar::Utilities::Module::m_config, Nektar::Utilities::Module::m_f, Vmath::Smul(), and Vmath::Vcopy().

70 {
71  if (m_f->m_verbose)
72  {
73  if(m_f->m_comm->GetRank() == 0)
74  {
75  cout << "ProcessC0Projection: Projecting field into C0 space..."
76  << endl;
77  }
78  }
79 
80  // ensure not using diagonal preconditioner since tends not to converge fo
81  // mass matrix
82  if(m_f->m_graph->GetMeshDimension() == 3)
83  {
84  if(boost::iequals(m_f->m_session->GetSolverInfo("GLOBALSYSSOLN"),
85  "IterativeStaticCond"))
86  {
87  if(boost::iequals(m_f->m_session->GetSolverInfo("PRECONDITIONER"),
88  "Diagonal"))
89  {
90  m_f->m_session->SetSolverInfo("PRECONDITIONER","LowEnergyBlock");
91  }
92  if(boost::iequals(m_f->m_session->GetSolverInfo("PRECONDITIONER"),
93  "FullLinearSpaceWithDiagonal"))
94  {
95  m_f->m_session->SetSolverInfo("PRECONDITIONER","FullLinearSpaceWithLowEnergyBlock");
96  }
97 
98  if(m_f->m_verbose)
99  {
100  if(m_f->m_comm->GetRank() == 0)
101  {
102  cout << "Resetting diagonal precondition to low energy block " << endl;
103  }
104  }
105  }
106  }
107  bool JustPerformLocToGloMap = m_config["localtoglobalmap"].as<bool>();
108  bool HelmSmoother = (boost::iequals(m_config["helmsmoothing"].as<string>(),"Not Set"))? false:true;
109  int nfields = m_f->m_exp.size();
110  Array<OneD, MultiRegions::ExpListSharedPtr> C0ProjectExp(nfields);
111  if(m_config["usexmlbcs"].as<bool>())
112  {
113  for(int i = 0; i < nfields; ++i)
114  {
115  C0ProjectExp[i] = m_f->m_exp[i];
116  }
117  }
118  else
119  {
120  // generate a C0 expansion field with no boundary conditions.
121  bool savedef = m_f->m_declareExpansionAsContField;
122  m_f->m_declareExpansionAsContField = true;
123  C0ProjectExp[0] = m_f->AppendExpList(m_f->m_fielddef[0]->m_numHomogeneousDir,
124  "DefaultVar",true);
125  m_f->m_declareExpansionAsContField = savedef;
126  for(int i = 1; i < nfields; ++i)
127  {
128  C0ProjectExp[i] = C0ProjectExp[0];
129  }
130  }
131 
132  string fields = m_config["fields"].as<string>();
133  vector<unsigned int> processFields;
134 
135  if(fields.compare("All") == 0)
136  {
137  for(int i = 0; i < nfields; ++i)
138  {
139  processFields.push_back(i);
140  }
141  }
142  else
143  {
145  processFields),
146  "Failed to interpret field string in C0Projection");
147  }
148 
149  for (int i = 0; i < processFields.size(); ++i)
150  {
151  ASSERTL0(processFields[i] < nfields,
152  "Attempt to process field that is larger than then number of "
153  "fields available");
154 
155  if (m_f->m_verbose)
156  {
157  if(m_f->m_comm->GetRank() == 0)
158  {
159  cout << "\t Processing field: " << processFields[i] << endl;
160  }
161  }
162 
163  if(JustPerformLocToGloMap)
164  {
165  int ncoeffs = m_f->m_exp[0]->GetNcoeffs();
166  Vmath::Vcopy(ncoeffs,m_f->m_exp[processFields[i]]->GetCoeffs(),1,
167  C0ProjectExp[processFields[i]]->UpdateCoeffs(),1);
168  C0ProjectExp[processFields[i]]->LocalToGlobal();
169  C0ProjectExp[processFields[i]]->GlobalToLocal();
170  Vmath::Vcopy(ncoeffs,C0ProjectExp[processFields[i]]->GetCoeffs(),1,
171  m_f->m_exp[processFields[i]]->UpdateCoeffs(),1);
172  }
173  else
174  {
175  if(HelmSmoother)
176  {
177  int dim = m_f->m_graph->GetSpaceDimension();
178  int npoints = m_f->m_exp[0]->GetNpoints();
179  NekDouble lambda = m_config["helmsmoothing"].as<NekDouble>();
180  lambda = 2*M_PI/lambda;
181  lambda = lambda*lambda;
182 
183  if(m_f->m_verbose)
184  {
185  cout << "Setting up Helmholtz smoother with lambda = " << lambda << endl;
186  }
187 
189  Array<OneD, NekDouble> forcing(npoints);
190  factors[StdRegions::eFactorLambda] = -lambda;
191 
192  Array<OneD, Array<OneD, NekDouble> > Velocity(dim);
193  for(int j =0; j < dim; ++j)
194  {
195  Velocity[j] = Array<OneD, NekDouble> (npoints,0.0);
196  }
197 
198  C0ProjectExp[processFields[i]]->BwdTrans(m_f->m_exp[processFields[i]]->GetCoeffs(),
199  m_f->m_exp[processFields[i]]->UpdatePhys());
200 
201  Vmath::Smul(npoints,-lambda,m_f->m_exp[processFields[i]]->GetPhys(),1,
202  forcing,1);
203 
204  // Note we are using the
205  // LinearAdvectionDiffusionReaction solver here
206  // instead of HelmSolve since lambda is negative and
207  // so matrices are not positive definite. Ideally
208  // should allow for negative lambda coefficient in
209  // HelmSolve
210  C0ProjectExp[processFields[i]]->LinearAdvectionDiffusionReactionSolve(Velocity,
211  forcing,
212  m_f->m_exp[processFields[i]]->UpdateCoeffs(),
213  -lambda);
214  }
215  else
216  {
217  C0ProjectExp[processFields[i]]->BwdTrans(m_f->m_exp[processFields[i]]->GetCoeffs(),
218  m_f->m_exp[processFields[i]]->UpdatePhys());
219  C0ProjectExp[processFields[i]]->FwdTrans(m_f->m_exp[processFields[i]]->GetPhys(),
220  m_f->m_exp[processFields[i]]->UpdateCoeffs());
221  }
222  }
223  }
224 
225  // reset FieldDef in case of serial input and parallel output
226  std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef
227  = m_f->m_exp[0]->GetFieldDefinitions();
228  // reset up FieldData with new values before projecting
229  std::vector<std::vector<NekDouble> > FieldData(FieldDef.size());
230 
231  for(int i = 0; i < nfields; ++i)
232  {
233  for (int j = 0; j < FieldDef.size(); ++j)
234  {
235  FieldDef[j]->m_fields.push_back(m_f->m_fielddef[0]->m_fields[i]);
236  m_f->m_exp[i]->AppendFieldData(FieldDef[j], FieldData[j]);
237  }
238  }
239 
240  m_f->m_fielddef = FieldDef;
241  m_f->m_data = FieldData;
242 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:188
static bool GenerateOrderedVector(const char *const str, std::vector< unsigned int > &vec)
Definition: ParseUtils.hpp:97
map< string, ConfigOption > m_config
List of configuration values.
std::map< ConstFactorType, NekDouble > ConstFactorMap
Definition: StdRegions.hpp:251
FieldSharedPtr m_f
Field object.
void Smul(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Scalar multiply y = alpha*y.
Definition: Vmath.cpp:199
double NekDouble
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.cpp:1047

Member Data Documentation

ModuleKey Nektar::Utilities::ProcessC0Projection::className
static
Initial value:

Definition at line 58 of file ProcessC0Projection.h.