*.sol の読み込み
Post date: 2015/05/04 9:15:42 (update 2021/05/31)
savesol() はあるが、readsol() はまだ整備途中?
とりあえず先頭8行分をスキップしてデータを読めます。
1変数
データ書き出し
fespace Vh1(Th,P1); Vh1 v;
savemesh(Th,"XXXX.mesh");
savesol("XXXX.sol",Th,v);
データ読み込み
Th=readmesh3("XXXX.mesh");
fespace Vh1(Th,P1); Vh1 v;
{
ifstream file("XXXX.sol");
for(int i=0; i < 8; i++) {getline(file,s); cout << "[sol]" << s << endl;}
for (int i=0; i < Th.nv; i++) {
file >> v[][i] ;
}
}
2変数
データ書き出し
fespace Vh1(Th,P1); Vh1 u, v;
savemesh(Th,"XXXX.mesh");
savesol("XXXX.sol",Th,u,v)
データ読み込み
Th=readmesh3("XXXX.mesh");
fespace Vh1(Th,P1); Vh1 u,v;
{
ifstream file("XXXX.sol");
for(int i=0; i<8; i++) {getline(file,s); cout << "[sol]" << s << endl;}
for (int i=0; i<Th.nv; i++) {
file >> u[][i] >> v[][i];
}
ベクトル変数を含む
データ書き出し
fespace Vh3(Th,[P1,P1,P1]); Vh3 [u1,u2,u3];
fespace Vh1(Th,P1); Vh1 v;
savemesh(Th,"XXXX.mesh");
savesol("XXXX.sol",Th,v,u1,u2,u3);
データ読み込み
Th=readmesh3("XXXX.mesh");
fespace Vh3(Th,[P1,P1,P1]); Vh3 [u1,u2,u3];
fespace Vh1(Th,P1); Vh1 v;
{
ifstream file("XXXX.sol");
for(int i=0; i<8; i++) {getline(file,s); cout << "[sol]" << s << endl;}
for (int i=0; i<Th.nv; i++) {
file >> v[][i] >> u1[][3*i] >> u1[][3*i+1] >> u1[][3*i+2];
}
}
補間をする場合は,スカラー変数へ代入したほうが便利
Th=readmesh3("XXXX.mesh");
fespace Vh1(Th,P1); Vh1 v, u1, u2, u3;
{
ifstream file("XXXX.sol");
for(int i=0; i<8; i++) getline(file,s); cout << "[sol]" << s << endl;
for (int i=0; i<Th.nv; i++) {
file >> v[][i] >> u1[][i] >> u2[][i] >> u3[][i];
}
}