50 ModuleKey ProcessC0Projection::className =
53 ProcessC0Projection::create,
54 "Computes C0 projection.");
60 true,
"0",
"Just perform a local to global mapping and back");
62 true,
"0",
"Use boundary conditions given in xml file. Requires all "
63 "projected fields to be defined in xml file");
65 false,
"Not Set",
"Use a Helmholtz smoother to remove high frequency "
66 "components above specified L");
68 f->m_declareExpansionAsContField =
true;
79 if (
m_f->m_comm->TreatAsRankZero())
81 cout <<
"ProcessC0Projection: Projecting field into C0 space..."
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_fielddef[0]->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);
193 int dim =
m_f->m_graph->GetSpaceDimension();
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 for (
int j = 0; j < dim; ++j)
215 C0ProjectExp[processFields[i]]->BwdTrans(
216 m_f->m_exp[processFields[i]]->GetCoeffs(),
217 m_f->m_exp[processFields[i]]->UpdatePhys());
220 m_f->m_exp[processFields[i]]->GetPhys(), 1, forcing,
229 C0ProjectExp[processFields[i]]
230 ->LinearAdvectionDiffusionReactionSolve(
232 m_f->m_exp[processFields[i]]->UpdateCoeffs(), -lambda);
236 C0ProjectExp[processFields[i]]->BwdTrans(
237 m_f->m_exp[processFields[i]]->GetCoeffs(),
238 m_f->m_exp[processFields[i]]->UpdatePhys());
239 C0ProjectExp[processFields[i]]->FwdTrans(
240 m_f->m_exp[processFields[i]]->GetPhys(),
241 m_f->m_exp[processFields[i]]->UpdateCoeffs());
247 std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef =
248 m_f->m_exp[0]->GetFieldDefinitions();
250 std::vector<std::vector<NekDouble> > FieldData(FieldDef.size());
252 for (
int i = 0; i < nfields; ++i)
254 for (
int j = 0; j < FieldDef.size(); ++j)
256 FieldDef[j]->m_fields.push_back(
m_f->m_fielddef[0]->m_fields[i]);
257 m_f->m_exp[i]->AppendFieldData(FieldDef[j], FieldData[j]);
261 m_f->m_fielddef = FieldDef;
262 m_f->m_data = FieldData;
map< string, ConfigOption > m_config
List of configuration values.
#define ASSERTL0(condition, msg)
static bool GenerateOrderedVector(const char *const str, std::vector< unsigned int > &vec)
Represents a command-line configuration option.
virtual ~ProcessC0Projection()
pair< ModuleType, string > ModuleKey
std::map< ConstFactorType, NekDouble > ConstFactorMap
void Smul(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Scalar multiply y = alpha*y.
boost::shared_ptr< Field > FieldSharedPtr
Abstract base class for processing modules.
virtual void Process(po::variables_map &vm)
Write mesh to output file.
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
ModuleFactory & GetModuleFactory()
FieldSharedPtr m_f
Field object.
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, tDescription pDesc="")
Register a class with the factory.