Write fld to output file.
70 string filename =
m_config[
"outfile"].as<
string>();
77 m_config[
"format"].as<string>(), c,
true);
79 if (
m_f->m_writeBndFld)
85 if (
m_f->m_comm->TreatAsRankZero())
87 cout <<
"OutputFld: Writing boundary file(s): ";
88 for (
int i = 0; i <
m_f->m_bndRegionsToWrite.size(); ++i)
90 cout <<
m_f->m_bndRegionsToWrite[i];
91 if (i < m_f->m_bndRegionsToWrite.size() - 1)
103 for (
int i = 0; i <
m_f->m_exp.size(); ++i)
105 m_f->m_exp[i]->FillBndCondFromField();
109 int nfields =
m_f->m_exp.size();
110 Array<OneD, Array<OneD, const MultiRegions::ExpListSharedPtr> > BndExp(
112 for (
int i = 0; i < nfields; ++i)
114 BndExp[i] =
m_f->m_exp[i]->GetBndCondExpansions();
119 SpatialDomains::BoundaryConditions bcs(
m_f->m_session,
120 m_f->m_exp[0]->GetGraph());
122 bcs.GetBoundaryRegions();
123 SpatialDomains::BoundaryRegionCollection::const_iterator breg_it;
124 map<int, int> BndRegionMap;
126 for (breg_it = bregions.begin(); breg_it != bregions.end();
129 BndRegionMap[breg_it->first] = cnt;
133 int dot = filename.find_last_of(
'.') + 1;
134 string ext = filename.substr(dot, filename.length() - dot);
135 string name = filename.substr(0, dot - 1);
137 for (
int i = 0; i <
m_f->m_bndRegionsToWrite.size(); ++i)
141 boost::lexical_cast<
string>(
m_f->m_bndRegionsToWrite[i]) +
"." +
144 std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef;
145 std::vector<std::vector<NekDouble> > FieldData;
147 if (BndRegionMap.count(
m_f->m_bndRegionsToWrite[i]) == 1)
149 int Border = BndRegionMap[
m_f->m_bndRegionsToWrite[i]];
151 FieldDef = BndExp[0][Border]->GetFieldDefinitions();
152 FieldData.resize(FieldDef.size());
154 for (
int j = 0; j < nfields; ++j)
156 for (
int k = 0; k < FieldDef.size(); ++k)
158 BndExp[j][Border]->AppendFieldData(FieldDef[k],
161 if (
m_f->m_fielddef.size() > 0)
163 FieldDef[k]->m_fields.push_back(
164 m_f->m_fielddef[0]->m_fields[j]);
168 FieldDef[k]->m_fields.push_back(
169 m_f->m_session->GetVariable(j));
174 if (
m_f->m_addNormals)
176 int normdim =
m_f->m_graph->GetMeshDimension();
177 string normstr[3] = {
"Norm_x",
"Norm_y",
"Norm_z"};
180 Array<OneD, Array<OneD, NekDouble> > NormPhys;
181 m_f->m_exp[0]->GetBoundaryNormals(Border, NormPhys);
184 for (
int j = 0; j < normdim; ++j)
186 BndExp[0][Border]->FwdTrans(
187 NormPhys[j], BndExp[0][Border]->UpdateCoeffs());
189 for (
int k = 0; k < FieldDef.size(); ++k)
191 BndExp[0][Border]->AppendFieldData(FieldDef[k],
193 FieldDef[k]->m_fields.push_back(normstr[j]);
199 if (vm.count(
"error"))
201 int rank =
m_f->m_session->GetComm()->GetRank();
203 for (
int j = 0; j < nfields; ++j)
205 BndExp[j][Border]->BwdTrans(
206 BndExp[j][Border]->GetCoeffs(),
207 BndExp[j][Border]->UpdatePhys());
213 BndExp[j][Border]->L2(BndExp[j][Border]->GetPhys());
215 NekDouble linferr = BndExp[j][Border]->Linf(
216 BndExp[j][Border]->GetPhys());
220 cout <<
"L 2 error (variable "
221 << FieldDef[0]->m_fields[j] <<
") : " << l2err
224 cout <<
"L inf error (variable "
225 << FieldDef[0]->m_fields[j]
226 <<
") : " << linferr << endl;
232 fld->Write(outname, FieldDef, FieldData,
m_f->m_fieldMetaDataMap);
239 if (
m_f->m_comm->TreatAsRankZero())
241 cout <<
"OutputFld: Writing file..." << endl;
247 if (fs::exists(
writefile) && (vm.count(
"forceoutput") == 0))
254 comm =
m_f->m_session->GetComm();
255 rank = comm->GetRank();
268 cout <<
"Did you wish to overwrite " << filename <<
" (y/n)? ";
269 getline(cin, answer);
270 if (answer.compare(
"y") == 0)
276 cout <<
"Not writing file " << filename
277 <<
" because it already exists" << endl;
286 fld->Write(filename,
m_f->m_fielddef,
m_f->m_data,
287 m_f->m_fieldMetaDataMap);
291 if (vm.count(
"error"))
293 int rank =
m_f->m_session->GetComm()->GetRank();
295 for (
int j = 0; j <
m_f->m_exp.size(); ++j)
297 if (
m_f->m_exp[j]->GetPhysState() ==
false)
299 m_f->m_exp[j]->BwdTrans(
m_f->m_exp[j]->GetCoeffs(),
300 m_f->m_exp[j]->UpdatePhys());
306 m_f->m_exp[j]->Linf(
m_f->m_exp[j]->GetPhys());
309 cout <<
"L 2 error (variable "
310 <<
m_f->m_fielddef[0]->m_fields[j] <<
") : " << l2err
313 cout <<
"L inf error (variable "
314 <<
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.