Write fld to output file.
70 string filename =
m_config[
"outfile"].as<
string>();
73 std::string iofmt(
"Xml");
76 if (
m_f->m_session->DefinesSolverInfo(
"IOFormat"))
78 iofmt =
m_f->m_session->GetSolverInfo(
"IOFormat");
80 if (
m_f->m_session->DefinesCmdLineArgument(
"io-format"))
83 m_f->m_session->GetCmdLineArgument<std::string>(
"io-format");
88 iofmt =
m_config[
"format"].as<
string>();
97 if (
m_f->m_writeBndFld)
103 if (
m_f->m_comm->TreatAsRankZero())
105 cout <<
"OutputFld: Writing boundary file(s): ";
106 for (
int i = 0; i <
m_f->m_bndRegionsToWrite.size(); ++i)
108 cout <<
m_f->m_bndRegionsToWrite[i];
109 if (i < m_f->m_bndRegionsToWrite.size() - 1)
121 for (
int i = 0; i <
m_f->m_exp.size(); ++i)
123 m_f->m_exp[i]->FillBndCondFromField();
127 int nfields =
m_f->m_exp.size();
128 Array<OneD, Array<OneD, const MultiRegions::ExpListSharedPtr> > BndExp(
130 for (
int i = 0; i < nfields; ++i)
132 BndExp[i] =
m_f->m_exp[i]->GetBndCondExpansions();
137 SpatialDomains::BoundaryConditions bcs(
m_f->m_session,
138 m_f->m_exp[0]->GetGraph());
140 bcs.GetBoundaryRegions();
141 SpatialDomains::BoundaryRegionCollection::const_iterator breg_it;
142 map<int, int> BndRegionMap;
144 for (breg_it = bregions.begin(); breg_it != bregions.end();
147 BndRegionMap[breg_it->first] = cnt;
151 int dot = filename.find_last_of(
'.') + 1;
152 string ext = filename.substr(dot, filename.length() - dot);
153 string name = filename.substr(0, dot - 1);
155 for (
int i = 0; i <
m_f->m_bndRegionsToWrite.size(); ++i)
159 boost::lexical_cast<
string>(
m_f->m_bndRegionsToWrite[i]) +
"." +
162 std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef;
163 std::vector<std::vector<NekDouble> > FieldData;
165 if (BndRegionMap.count(
m_f->m_bndRegionsToWrite[i]) == 1)
167 int Border = BndRegionMap[
m_f->m_bndRegionsToWrite[i]];
169 FieldDef = BndExp[0][Border]->GetFieldDefinitions();
170 FieldData.resize(FieldDef.size());
172 for (
int j = 0; j < nfields; ++j)
174 for (
int k = 0; k < FieldDef.size(); ++k)
176 BndExp[j][Border]->AppendFieldData(FieldDef[k],
179 if (
m_f->m_fielddef.size() > 0)
181 FieldDef[k]->m_fields.push_back(
182 m_f->m_fielddef[0]->m_fields[j]);
186 FieldDef[k]->m_fields.push_back(
187 m_f->m_session->GetVariable(j));
192 if (
m_f->m_addNormals)
194 int normdim =
m_f->m_graph->GetMeshDimension();
195 string normstr[3] = {
"Norm_x",
"Norm_y",
"Norm_z"};
198 Array<OneD, Array<OneD, NekDouble> > NormPhys;
199 m_f->m_exp[0]->GetBoundaryNormals(Border, NormPhys);
202 for (
int j = 0; j < normdim; ++j)
204 BndExp[0][Border]->FwdTrans(
205 NormPhys[j], BndExp[0][Border]->UpdateCoeffs());
207 for (
int k = 0; k < FieldDef.size(); ++k)
209 BndExp[0][Border]->AppendFieldData(FieldDef[k],
211 FieldDef[k]->m_fields.push_back(normstr[j]);
217 if (vm.count(
"error"))
219 int rank =
m_f->m_session->GetComm()->GetRank();
221 for (
int j = 0; j < nfields; ++j)
223 BndExp[j][Border]->BwdTrans(
224 BndExp[j][Border]->GetCoeffs(),
225 BndExp[j][Border]->UpdatePhys());
231 BndExp[j][Border]->L2(BndExp[j][Border]->GetPhys());
233 NekDouble linferr = BndExp[j][Border]->Linf(
234 BndExp[j][Border]->GetPhys());
238 cout <<
"L 2 error (variable "
239 << FieldDef[0]->m_fields[j] <<
") : " << l2err
242 cout <<
"L inf error (variable "
243 << FieldDef[0]->m_fields[j]
244 <<
") : " << linferr << endl;
250 fld->Write(outname, FieldDef, FieldData,
m_f->m_fieldMetaDataMap);
257 if (
m_f->m_comm->TreatAsRankZero())
259 cout <<
"OutputFld: Writing file..." << endl;
265 if (fs::exists(
writefile) && (vm.count(
"forceoutput") == 0))
272 comm =
m_f->m_session->GetComm();
273 rank = comm->GetRank();
286 cout <<
"Did you wish to overwrite " << filename <<
" (y/n)? ";
287 getline(cin, answer);
288 if (answer.compare(
"y") == 0)
294 cout <<
"Not writing file " << filename
295 <<
" because it already exists" << endl;
304 fld->Write(filename,
m_f->m_fielddef,
m_f->m_data,
305 m_f->m_fieldMetaDataMap);
309 if (vm.count(
"error"))
311 int rank =
m_f->m_session->GetComm()->GetRank();
313 for (
int j = 0; j <
m_f->m_exp.size(); ++j)
315 if (
m_f->m_exp[j]->GetPhysState() ==
false)
317 m_f->m_exp[j]->BwdTrans(
m_f->m_exp[j]->GetCoeffs(),
318 m_f->m_exp[j]->UpdatePhys());
324 m_f->m_exp[j]->Linf(
m_f->m_exp[j]->GetPhys());
327 cout <<
"L 2 error (variable "
328 <<
m_f->m_fielddef[0]->m_fields[j] <<
") : " << l2err
331 cout <<
"L inf error (variable "
332 <<
m_f->m_fielddef[0]->m_fields[j] <<
") : " << linferr
map< string, ConfigOption > m_config
List of configuration values.
tBaseSharedPtr CreateInstance(tKey idKey BOOST_PP_COMMA_IF(MAX_PARAM) BOOST_PP_ENUM_BINARY_PARAMS(MAX_PARAM, tParam, x))
Create an instance of the class referred to by idKey.
pair< ModuleType, string > ModuleKey
FieldIOFactory & GetFieldIOFactory()
Returns the FieldIO factory.
CommFactory & GetCommFactory()
boost::shared_ptr< Comm > CommSharedPtr
Pointer to a Communicator object.
std::map< int, BoundaryRegionShPtr > BoundaryRegionCollection
boost::shared_ptr< FieldIO > FieldIOSharedPtr
FieldSharedPtr m_f
Field object.