Init_Solution_mult (initialize on subdomains) + finer mesh
This commit is contained in:
parent
b1303a8b4a
commit
bd4477f062
7 changed files with 46889 additions and 2124 deletions
|
|
@ -34,7 +34,7 @@ g=[2 -diam_bottom/2 diam_bottom/2 floor_level floor_level 1 0; % #vert
|
||||||
]';
|
]';
|
||||||
|
|
||||||
|
|
||||||
[p,e,t] = initmesh(g,'hmax',10);
|
[p,e,t] = initmesh(g,'hmax',1.5);
|
||||||
pdemesh(p,e,t)
|
pdemesh(p,e,t)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -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
|
void Mesh::Debug() const
|
||||||
{
|
{
|
||||||
|
|
@ -958,10 +982,6 @@ Mesh::Mesh(std::string const &fname)
|
||||||
//cout << " P E R M U T E D !" << endl;
|
//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)
|
Mesh::Mesh(std::string const &filename, std::string const &subdomain_filename) : Mesh(filename)
|
||||||
{
|
{
|
||||||
ElementSubdomains = ReadElementSubdomains(subdomain_filename);
|
ElementSubdomains = ReadElementSubdomains(subdomain_filename);
|
||||||
|
|
|
||||||
|
|
@ -199,6 +199,17 @@ public:
|
||||||
const std::function<double(double, double, double)> &func1,
|
const std::function<double(double, double, double)> &func1,
|
||||||
const std::function<double(double, double, double)> &func2 ) const;
|
const std::function<double(double, double, double)> &func2 ) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize values in vector valued vector @p v via functions @p func?(x,y) only
|
||||||
|
* on elements (all their vertices) that belong to subdomain @p target_sd
|
||||||
|
* @param[in] v vector
|
||||||
|
* @param[in] target_sd integer of target subdomain.
|
||||||
|
* @param[in] func function of (x,y) returning a double value.
|
||||||
|
*/
|
||||||
|
void Init_Solution_mult(std::vector<double> &v,
|
||||||
|
int target_sd,
|
||||||
|
const std::function<double(double, double)> &func) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prints the information for a finite element mesh
|
* Prints the information for a finite element mesh
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -57,8 +57,9 @@ int main(int argc, char **argv )
|
||||||
|
|
||||||
// Initialize temperature
|
// Initialize temperature
|
||||||
vector<double> uv(SK.Nrows(), 0.0); // temperature
|
vector<double> uv(SK.Nrows(), 0.0); // temperature
|
||||||
mesh.SetValues(uv, [](double x, double y) -> double { return 18; } ); // initial temperature of every domain
|
mesh.Init_Solution_mult(uv, 0, [](double x, double y) -> double { return 18; }); // mug
|
||||||
|
mesh.Init_Solution_mult(uv, 1, [](double x, double y) -> double { return 80; }); // fluid
|
||||||
|
mesh.Init_Solution_mult(uv, 2, [](double x, double y) -> double { return 18; }); // air
|
||||||
|
|
||||||
// Apply BC
|
// Apply BC
|
||||||
SK.ApplyDirichletBC(uv, fv);
|
SK.ApplyDirichletBC(uv, fv);
|
||||||
|
|
@ -70,7 +71,7 @@ int main(int argc, char **argv )
|
||||||
|
|
||||||
auto t3 = system_clock::now(); // start timer
|
auto t3 = system_clock::now(); // start timer
|
||||||
|
|
||||||
JacobiSolve(SK, fv, uv ); // solve the system of equations
|
// JacobiSolve(SK, fv, uv ); // solve the system of equations
|
||||||
|
|
||||||
auto t4 = system_clock::now(); // stop timer
|
auto t4 = system_clock::now(); // stop timer
|
||||||
auto duration = duration_cast<microseconds>(t4 - t3); // duration in microseconds
|
auto duration = duration_cast<microseconds>(t4 - t3); // duration in microseconds
|
||||||
|
|
|
||||||
21823
mgrid_2/uv.txt
21823
mgrid_2/uv.txt
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue