added subdomain support in Mesh class, CalculateLaplaceMult implementation

This commit is contained in:
jakob.schratter 2026-01-22 17:52:23 +01:00
commit 2e887c04bc
13 changed files with 4336 additions and 69057 deletions

View file

@ -236,6 +236,7 @@ void Mesh::Export_scicomp(std::string const &basename) const
return;
}
// subject to permutation:
// re-sort: _xc
// _xc[2*k_new], _xc[2*k_new+1] with k_new = po2n[k] via old(_xc);
@ -283,9 +284,10 @@ void Mesh::Visualize(vector<double> const &v) const
void Mesh::Visualize_matlab(vector<double> const &v) const
{
// define external command
const string exec_m("matlab -nosplash < visualize_results.m"); // Matlab
//const string exec_m("matlab -nosplash < visualize_results.m"); // Matlab
//const string exec_m("octave --no-window-system --no-gui visualize_results.m"); // Octave
//const string exec_m("flatpak run org.octave.Octave visualize_results.m"); // Octave (flatpak): desktop GH
const string exec_m("octave visualize_results.m");
const string fname("uv.txt");
Write_ascii_matlab(fname, v);
@ -956,6 +958,45 @@ Mesh::Mesh(std::string const &fname)
//cout << " P E R M U T E D !" << endl;
}
vector<int> ElementSubdomains;
Mesh::Mesh(std::string const &filename, std::string const &subdomain_filename) : Mesh(filename)
{
ElementSubdomains = ReadElementSubdomains(subdomain_filename);
}
const vector<int> Mesh::ReadElementSubdomains(string const &dname) const
{
ifstream ifs(dname);
if (!(ifs.is_open() && ifs.good())) {
cerr << "ParMesh::ReadElementSubdomain: Error cannot open file " << dname << endl;
assert(ifs.is_open());
}
int const OFFSET{1}; // Matlab to C indexing
cout << "ASCI file " << dname << " opened" << endl;
// Read some mesh constants
int nelem;
ifs >> nelem;
cout << nelem << " " << Nelems() << endl;
assert( Nelems() == nelem);
// Allocate memory
vector<int> t2d(nelem, -1);
// Read element mapping
for (int k = 0; k < nelem; ++k) {
int tmp;
ifs >> tmp;
t2d[k] = tmp - OFFSET;
}
return t2d;
}
void Mesh::ReadVertexBasedMesh(std::string const &fname)
{
ifstream ifs(fname);