Ofppで読み出すと,internalFieldやboundaryFieldのデータがそのまま出力されるので,確かに空間情報(座標の情報)は
出てきません。
でも,対応するcellやfaceの順番は変わらないので,別途OpenFOAM上でセルの座標等を出力しておけば,
その座標のデータと併用することで,どのデータがどのセルのデータかはわかると思います。
自分は下記のようなコードをソルバに組み込んで,座標データをCSVで出力して使ってます。
ただ,最近,functionObjectにwriteCellCentresというのがあるのを見つけたので,簡単に座標を出力できるような気もします。
//const fileName path = "postProcessing";
const fileName path = ".";
if(!isDir(path)) mkDir(path);
const fileName fnamecelinfo = path / "cellCoord.csv";
OFstream fout(fnamecelinfo);
forAll(mesh.cells(), cid)
{
const vector &C = mesh.C()[cid];
fout<<C.x()<<","<<C.y()<<","<<C.z()<<endl;
}
const fileName fnamecelvinfo = path / "cellVolume.csv";
OFstream fout2(fnamecelvinfo);
forAll(mesh.cells(), cid)
{
const scalar V = mesh.V()[cid];
fout2<< V <<endl;
}
const fvPatchList& patches = mesh.boundary();
forAll(patches, patchi)
{
fileName fnamecfinfo = "Cf-"+patches[patchi].name() + ".csv";
OFstream fout3(fnamecfinfo);
Info << patches[patchi].name() <<endl;
const labelUList& pFaceCells =
mesh.boundary()[patchi].faceCells();
forAll(pFaceCells, facei)
{
const vector &f = mesh.boundary()[patchi].Cf()[facei];
fout3<<f.x()<<","<<f.y()<<","<<f.z()<<endl;
}
//}
}
2025年4月18日金曜日 16:38:46 UTC+9 mtzn: