1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130
|
//
// Read solution file
//
#include "visual_api.hpp"
#include <mystdlib.h>
#include <myadt.hpp>
#include <linalg.hpp>
#include <csg.hpp>
#include <meshing.hpp>
#include <nginterface.h>
namespace netgen
{
DLL_HEADER extern shared_ptr<Mesh> mesh;
NGGUI_API void ImportSolution2 (const char * filename)
{
ifstream inf (filename);
char buf[100], name[1000];
int i, size, comps, order;
bool iscomplex;
std::string type;
Flags flags;
while (1)
{
buf[0] = 0;
inf >> buf;
if (strcmp (buf, "solution") == 0)
{
inf >> name;
inf >> buf[0];
flags.DeleteFlags ();
while (buf[0] == '-')
{
inf >> buf[1];
inf.putback (buf[1]);
if (!isalpha (buf[1]))
{
break;
}
inf >> (buf+1);
flags.SetCommandLineFlag (buf);
buf[0] = 0;
inf >> buf[0];
}
inf.putback (buf[0]);
(*testout) << "Flags: " << endl;
flags.PrintFlags (*testout);
(*testout) << "done" << endl;
size = int(flags.GetNumFlag ("size", mesh->GetNP())); // Ng_GetNP()));
comps = int(flags.GetNumFlag ("components", 1));
type = flags.GetStringFlag ("type", "nodal");
order = int(flags.GetNumFlag ("order", 1));
iscomplex = flags.GetDefineFlag ("complex");
double * sol = new double[size*comps];
(*testout) << "import solution " << name << " size = " << size << " comps = " << comps << " order = " << order << endl;
for (i = 0; i < size*comps; i++)
{
inf >> sol[i];
// (*testout) << "sol: " << sol[i] << endl;
}
Ng_SolutionData soldata;
Ng_InitSolutionData (&soldata);
soldata.name = name;
soldata.data = sol;
soldata.dist = comps;
soldata.components = comps;
soldata.order = order;
soldata.iscomplex = iscomplex;
soldata.soltype = NG_SOLUTION_NODAL;
soldata.draw_surface = 1;
soldata.draw_volume = 1;
if (type == "element")
{
soldata.soltype = NG_SOLUTION_ELEMENT;
soldata.draw_surface = 0;
}
if (type == "surfaceelement")
{
soldata.soltype = NG_SOLUTION_SURFACE_ELEMENT;
soldata.draw_volume = 0;
}
if (type == "noncontinuous")
soldata.soltype = NG_SOLUTION_NONCONTINUOUS;
if (type == "surfacenoncontinuous")
soldata.soltype = NG_SOLUTION_SURFACE_NONCONTINUOUS;
Ng_SetSolutionData (&soldata);
}
else
{
// cout << "kw = (" << buf << ")" << endl;
(*testout) << "kw = (" << buf << ")" << endl;
break;
}
}
/*
struct Ng_SolutionData
{
char * name; // name of gridfunction
double * data; // solution values
int components; // used components in solution vector
int dist; // num of doubles per entry (alignment!)
Ng_SolutionType soltype; // type of solution function
};
// initialize solution data with default arguments
void Ng_InitSolutionData (Ng_SolutionData * soldata);
// set solution data
void Ng_SetSolutionData (Ng_SolutionData * soldata);
*/
}
}
|