Init_Solution_mult (initialize on subdomains) + finer mesh

This commit is contained in:
dino.celebic 2026-01-23 17:43:13 +01:00
commit bd4477f062
7 changed files with 46889 additions and 2124 deletions

View file

@ -67,6 +67,30 @@ void Mesh::SetValues(std::vector<double> &vvec,
}
}
void Mesh::Init_Solution_mult(std::vector<double> &v,
int target_sd,
const function<double(double, double)> &func) const
{
assert(2==Ndims());
int const nnode = Nnodes(); // number of vertices in mesh
assert( nnode == static_cast<int>(v.size()) );
for (int e = 0; e < Nelems(); ++e) // loop over all elements
{
int sd = ElementSubdomains[e]; // get subdomain of element e
if (sd == target_sd) // if is target subdomain then
{
int base = e * _nvert_e; // get starting index of element in coordinate vector
for (int k = 0; k < _nvert_e; ++k) // loop over vertices of element
{
int node = _ia[base + k]; // global index of vertex
v[node] = func( _xc[2 * node], _xc[2 * node + 1] ); // set function
}
}
}
}
void Mesh::Debug() const
{
@ -958,14 +982,10 @@ 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);
}
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
{