Nektar++
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | List of all members
Nektar::FieldUtils::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::FieldUtils::ProcessC0Projection:
[legend]

Public Member Functions

 ProcessC0Projection (FieldSharedPtr f)
 
 ~ProcessC0Projection () override
 
- Public Member Functions inherited from Nektar::FieldUtils::ProcessModule
 ProcessModule ()
 
 ProcessModule (FieldSharedPtr p_f)
 
- Public Member Functions inherited from Nektar::FieldUtils::Module
FIELD_UTILS_EXPORT Module (FieldSharedPtr p_f)
 
virtual ~Module ()=default
 
void Process (po::variables_map &vm)
 
std::string GetModuleName ()
 
std::string GetModuleDescription ()
 
const ConfigOptionGetConfigOption (const std::string &key) const
 
ModulePriority GetModulePriority ()
 
std::vector< ModuleKeyGetModulePrerequisites ()
 
FIELD_UTILS_EXPORT void RegisterConfig (std::string key, std::string value="")
 Register a configuration option with a module. More...
 
FIELD_UTILS_EXPORT void PrintConfig ()
 Print out all configuration options for a module. More...
 
FIELD_UTILS_EXPORT void SetDefaults ()
 Sets default configuration options for those which have not been set. More...
 
FIELD_UTILS_EXPORT void AddFile (std::string fileType, std::string fileName)
 
FIELD_UTILS_EXPORT void EvaluateTriFieldAtEquiSpacedPts (LocalRegions::ExpansionSharedPtr &exp, const Array< OneD, const NekDouble > &infield, Array< OneD, NekDouble > &outfield)
 

Static Public Member Functions

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

Static Public Attributes

static ModuleKey className
 

Protected Member Functions

void v_Process (po::variables_map &vm) override
 Write mesh to output file. More...
 
std::string v_GetModuleName () override
 
std::string v_GetModuleDescription () override
 
ModulePriority v_GetModulePriority () override
 
- Protected Member Functions inherited from Nektar::FieldUtils::Module
 Module ()
 
virtual void v_Process (po::variables_map &vm)
 
virtual std::string v_GetModuleName ()
 
virtual std::string v_GetModuleDescription ()
 
virtual ModulePriority v_GetModulePriority ()
 
virtual std::vector< ModuleKeyv_GetModulePrerequisites ()
 

Additional Inherited Members

- Public Attributes inherited from Nektar::FieldUtils::Module
FieldSharedPtr m_f
 Field object. More...
 
- Protected Attributes inherited from Nektar::FieldUtils::Module
std::map< std::string, ConfigOptionm_config
 List of configuration values. More...
 
std::set< std::string > m_allowedFiles
 List of allowed file formats. More...
 

Detailed Description

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

Definition at line 47 of file ProcessC0Projection.h.

Constructor & Destructor Documentation

◆ ProcessC0Projection()

Nektar::FieldUtils::ProcessC0Projection::ProcessC0Projection ( FieldSharedPtr  f)

Definition at line 52 of file ProcessC0Projection.cpp.

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

References Nektar::FieldUtils::Module::m_config.

◆ ~ProcessC0Projection()

Nektar::FieldUtils::ProcessC0Projection::~ProcessC0Projection ( )
override

Definition at line 69 of file ProcessC0Projection.cpp.

70{
71}

Member Function Documentation

◆ create()

static std::shared_ptr< Module > Nektar::FieldUtils::ProcessC0Projection::create ( FieldSharedPtr  f)
inlinestatic

Creates an instance of this class.

Definition at line 51 of file ProcessC0Projection.h.

52 {
54 }
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.

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

◆ v_GetModuleDescription()

std::string Nektar::FieldUtils::ProcessC0Projection::v_GetModuleDescription ( )
inlineoverrideprotectedvirtual

Reimplemented from Nektar::FieldUtils::Module.

Definition at line 69 of file ProcessC0Projection.h.

70 {
71 return "Projecting field into C0 space";
72 }

◆ v_GetModuleName()

std::string Nektar::FieldUtils::ProcessC0Projection::v_GetModuleName ( )
inlineoverrideprotectedvirtual

Reimplemented from Nektar::FieldUtils::Module.

Definition at line 64 of file ProcessC0Projection.h.

65 {
66 return "ProcessC0Projection";
67 }

◆ v_GetModulePriority()

ModulePriority Nektar::FieldUtils::ProcessC0Projection::v_GetModulePriority ( )
inlineoverrideprotectedvirtual

Reimplemented from Nektar::FieldUtils::Module.

Definition at line 74 of file ProcessC0Projection.h.

75 {
76 return eModifyExp;
77 }

References Nektar::FieldUtils::eModifyExp.

◆ v_Process()

void Nektar::FieldUtils::ProcessC0Projection::v_Process ( po::variables_map &  vm)
overrideprotectedvirtual

Write mesh to output file.

Reimplemented from Nektar::FieldUtils::Module.

Definition at line 73 of file ProcessC0Projection.cpp.

74{
75 m_f->SetUpExp(vm);
76
77 // Skip in case of empty partition
78 if (m_f->m_exp[0]->GetNumElmts() == 0)
79 {
80 return;
81 }
82
83 // ensure not using diagonal preconditioner since tends not to converge for
84 // mass matrix
85 if (m_f->m_graph->GetMeshDimension() == 3)
86 {
87 if (boost::iequals(m_f->m_session->GetSolverInfo("GLOBALSYSSOLN"),
88 "IterativeStaticCond"))
89 {
90 if (boost::iequals(m_f->m_session->GetSolverInfo("PRECONDITIONER"),
91 "Diagonal"))
92 {
93 m_f->m_session->SetSolverInfo("PRECONDITIONER",
94 "LowEnergyBlock");
95 }
96 if (boost::iequals(m_f->m_session->GetSolverInfo("PRECONDITIONER"),
97 "FullLinearSpaceWithDiagonal"))
98 {
99 m_f->m_session->SetSolverInfo(
100 "PRECONDITIONER", "FullLinearSpaceWithLowEnergyBlock");
101 }
102
103 if (m_f->m_verbose)
104 {
105 if (m_f->m_comm->GetRank() == 0)
106 {
107 cout << "Resetting diagonal precondition to low energy "
108 "block "
109 << endl;
110 }
111 }
112 }
113 }
114 bool JustPerformLocToGloMap = m_config["localtoglobalmap"].as<bool>();
115 bool HelmSmoother =
116 (boost::iequals(m_config["helmsmoothing"].as<string>(), "Not Set"))
117 ? false
118 : true;
119 int nfields = m_f->m_exp.size();
120 Array<OneD, MultiRegions::ExpListSharedPtr> C0ProjectExp(nfields);
121 if (m_config["usexmlbcs"].as<bool>())
122 {
123 for (int i = 0; i < nfields; ++i)
124 {
125 C0ProjectExp[i] = m_f->m_exp[i];
126 }
127 }
128 else
129 {
130 // generate a C0 expansion field with no boundary conditions.
131 bool savedef = m_f->m_declareExpansionAsContField;
132 bool savedef2 = m_f->m_requireBoundaryExpansion;
133 m_f->m_declareExpansionAsContField = true;
134 m_f->m_requireBoundaryExpansion = false;
135 C0ProjectExp[0] =
136 m_f->AppendExpList(m_f->m_numHomogeneousDir, "DefaultVar", true);
137 m_f->m_declareExpansionAsContField = savedef;
138 m_f->m_requireBoundaryExpansion = savedef2;
139 for (int i = 1; i < nfields; ++i)
140 {
141 C0ProjectExp[i] = C0ProjectExp[0];
142 }
143 }
144
145 string fields = m_config["fields"].as<string>();
146 vector<unsigned int> processFields;
147 Array<OneD, NekDouble> tmp;
148
149 if (fields.compare("All") == 0)
150 {
151 for (int i = 0; i < nfields; ++i)
152 {
153 processFields.push_back(i);
154 }
155 }
156 else
157 {
158 ASSERTL0(ParseUtils::GenerateVector(fields, processFields),
159 "Failed to interpret field string in C0Projection");
160 }
161
162 for (int i = 0; i < processFields.size(); ++i)
163 {
164 ASSERTL0(processFields[i] < nfields,
165 "Attempt to process field that is larger than then number of "
166 "fields available");
167
168 if (m_f->m_verbose)
169 {
170 if (m_f->m_comm->GetRank() == 0)
171 {
172 cout << "\t Processing field: " << processFields[i] << endl;
173 }
174 }
175
176 if (JustPerformLocToGloMap)
177 {
178 int ncoeffs = m_f->m_exp[0]->GetNcoeffs();
179 Array<OneD, NekDouble> Coeffs(ncoeffs);
180 Vmath::Vcopy(ncoeffs, m_f->m_exp[processFields[i]]->GetCoeffs(), 1,
181 Coeffs, 1);
182 C0ProjectExp[processFields[i]]->LocalToGlobal(Coeffs, Coeffs);
183 C0ProjectExp[processFields[i]]->GlobalToLocal(Coeffs, Coeffs);
184
185 Vmath::Vcopy(ncoeffs, Coeffs, 1,
186 tmp = m_f->m_exp[processFields[i]]->UpdateCoeffs(), 1);
187 }
188 else
189 {
190 int ncoeffs = m_f->m_exp[0]->GetNcoeffs();
191 if (HelmSmoother)
192 {
193 int npoints = m_f->m_exp[0]->GetNpoints();
194 NekDouble lambda = m_config["helmsmoothing"].as<NekDouble>();
195 lambda = 2 * M_PI / lambda;
196 lambda = lambda * lambda;
197
198 if (m_f->m_verbose)
199 {
200 cout << "Setting up Helmholtz smoother with lambda = "
201 << lambda << endl;
202 }
203
205 Array<OneD, NekDouble> forcing(npoints);
207
208 Vmath::Smul(npoints, -lambda,
209 m_f->m_exp[processFields[i]]->GetPhys(), 1, forcing,
210 1);
211 Vmath::Zero(ncoeffs,
212 m_f->m_exp[processFields[i]]->UpdateCoeffs(), 1);
213 C0ProjectExp[processFields[i]]->HelmSolve(
214 forcing, m_f->m_exp[processFields[i]]->UpdateCoeffs(),
215 factors);
216 }
217 else
218 {
219 Vmath::Zero(ncoeffs,
220 m_f->m_exp[processFields[i]]->UpdateCoeffs(), 1);
221 C0ProjectExp[processFields[i]]->FwdTrans(
222 m_f->m_exp[processFields[i]]->GetPhys(),
223 m_f->m_exp[processFields[i]]->UpdateCoeffs());
224 }
225 }
226 C0ProjectExp[processFields[i]]->BwdTrans(
227 m_f->m_exp[processFields[i]]->GetCoeffs(),
228 tmp = m_f->m_exp[processFields[i]]->UpdatePhys());
229 }
230}
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:208
FieldSharedPtr m_f
Field object.
Definition: Module.h:239
static bool GenerateVector(const std::string &str, std::vector< T > &out)
Takes a comma-separated string and converts it to entries in a vector.
Definition: ParseUtils.cpp:130
std::map< ConstFactorType, NekDouble > ConstFactorMap
Definition: StdRegions.hpp:430
StdRegions::ConstFactorMap factors
double NekDouble
void Smul(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Scalar multiply y = alpha*x.
Definition: Vmath.hpp:100
void Zero(int n, T *x, const int incx)
Zero vector.
Definition: Vmath.hpp:273
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.hpp:825

References ASSERTL0, Nektar::StdRegions::eFactorLambda, Nektar::VarcoeffHashingTest::factors, Nektar::ParseUtils::GenerateVector(), Nektar::FieldUtils::Module::m_config, Nektar::FieldUtils::Module::m_f, Vmath::Smul(), Vmath::Vcopy(), and Vmath::Zero().

Member Data Documentation

◆ className

ModuleKey Nektar::FieldUtils::ProcessC0Projection::className
static
Initial value:
=
"Computes C0 projection.")
static std::shared_ptr< Module > create(FieldSharedPtr f)
Creates an instance of this class.
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
std::pair< ModuleType, std::string > ModuleKey
Definition: Module.h:180
ModuleFactory & GetModuleFactory()
Definition: Module.cpp:47

Definition at line 55 of file ProcessC0Projection.h.