39 #include <boost/core/ignore_unused.hpp>
51 ModuleKey ProcessC0Projection::className =
54 ProcessC0Projection::create,
55 "Computes C0 projection.");
61 true,
"0",
"Just perform a local to global mapping and back");
63 true,
"0",
"Use boundary conditions given in xml file. Requires all "
64 "projected fields to be defined in xml file");
66 false,
"Not Set",
"Use a Helmholtz smoother to remove high frequency "
67 "components above specified L");
69 f->m_declareExpansionAsContField =
true;
81 if (
m_f->m_exp[0]->GetNumElmts() == 0)
88 if (
m_f->m_graph->GetMeshDimension() == 3)
90 if (boost::iequals(
m_f->m_session->GetSolverInfo(
"GLOBALSYSSOLN"),
91 "IterativeStaticCond"))
93 if (boost::iequals(
m_f->m_session->GetSolverInfo(
"PRECONDITIONER"),
96 m_f->m_session->SetSolverInfo(
"PRECONDITIONER",
99 if (boost::iequals(
m_f->m_session->GetSolverInfo(
"PRECONDITIONER"),
100 "FullLinearSpaceWithDiagonal"))
102 m_f->m_session->SetSolverInfo(
103 "PRECONDITIONER",
"FullLinearSpaceWithLowEnergyBlock");
108 if (
m_f->m_comm->GetRank() == 0)
110 cout <<
"Resetting diagonal precondition to low energy "
117 bool JustPerformLocToGloMap =
m_config[
"localtoglobalmap"].as<
bool>();
119 (boost::iequals(
m_config[
"helmsmoothing"].as<string>(),
"Not Set"))
122 int nfields =
m_f->m_exp.size();
124 if (
m_config[
"usexmlbcs"].as<bool>())
126 for (
int i = 0; i < nfields; ++i)
128 C0ProjectExp[i] =
m_f->m_exp[i];
134 bool savedef =
m_f->m_declareExpansionAsContField;
135 bool savedef2 =
m_f->m_requireBoundaryExpansion;
136 m_f->m_declareExpansionAsContField =
true;
137 m_f->m_requireBoundaryExpansion =
false;
138 C0ProjectExp[0] =
m_f->AppendExpList(
139 m_f->m_numHomogeneousDir,
"DefaultVar",
true);
140 m_f->m_declareExpansionAsContField = savedef;
141 m_f->m_requireBoundaryExpansion = savedef2;
142 for (
int i = 1; i < nfields; ++i)
144 C0ProjectExp[i] = C0ProjectExp[0];
148 string fields =
m_config[
"fields"].as<
string>();
149 vector<unsigned int> processFields;
151 if (fields.compare(
"All") == 0)
153 for (
int i = 0; i < nfields; ++i)
155 processFields.push_back(i);
162 "Failed to interpret field string in C0Projection");
165 for (
int i = 0; i < processFields.size(); ++i)
167 ASSERTL0(processFields[i] < nfields,
168 "Attempt to process field that is larger than then number of "
173 if (
m_f->m_comm->GetRank() == 0)
175 cout <<
"\t Processing field: " << processFields[i] << endl;
179 if (JustPerformLocToGloMap)
181 int ncoeffs =
m_f->m_exp[0]->GetNcoeffs();
183 C0ProjectExp[processFields[i]]->UpdateCoeffs(), 1);
184 C0ProjectExp[processFields[i]]->LocalToGlobal();
185 C0ProjectExp[processFields[i]]->GlobalToLocal();
186 Vmath::Vcopy(ncoeffs, C0ProjectExp[processFields[i]]->GetCoeffs(),
187 1,
m_f->m_exp[processFields[i]]->UpdateCoeffs(), 1);
191 int ncoeffs =
m_f->m_exp[0]->GetNcoeffs();
194 int npoints =
m_f->m_exp[0]->GetNpoints();
196 lambda = 2 * M_PI / lambda;
197 lambda = lambda * lambda;
201 cout <<
"Setting up Helmholtz smoother with lambda = "
210 m_f->m_exp[processFields[i]]->GetPhys(), 1, forcing,
213 Vmath::Zero(ncoeffs,
m_f->m_exp[processFields[i]]->UpdateCoeffs(),1);
215 C0ProjectExp[processFields[i]]->HelmSolve(forcing,
216 m_f->m_exp[processFields[i]]->UpdateCoeffs(), factors);
220 Vmath::Zero(ncoeffs,
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());
226 C0ProjectExp[processFields[i]]->BwdTrans(
227 m_f->m_exp[processFields[i]]->GetCoeffs(),
228 m_f->m_exp[processFields[i]]->UpdatePhys());
#define ASSERTL0(condition, msg)
FieldSharedPtr m_f
Field object.
std::map< std::string, ConfigOption > m_config
List of configuration values.
virtual void Process(po::variables_map &vm)
Write mesh to output file.
virtual ~ProcessC0Projection()
Abstract base class for processing modules.
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
static bool GenerateVector(const std::string &str, std::vector< T > &out)
Takes a comma-separated string and converts it to entries in a vector.
std::shared_ptr< Field > FieldSharedPtr
std::pair< ModuleType, std::string > ModuleKey
ModuleFactory & GetModuleFactory()
std::map< ConstFactorType, NekDouble > ConstFactorMap
The above copyright notice and this permission notice shall be included.
void Smul(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Scalar multiply y = alpha*x.
void Zero(int n, T *x, const int incx)
Zero vector.
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Represents a command-line configuration option.