Commit a2d5243c authored by Kirill Terekhov's avatar Kirill Terekhov

Synchronize

Some features for class Residual.

Clean-ups in xml.

Updated MFD.
parent 7d30608c
......@@ -182,7 +182,6 @@ int main(int argc,char ** argv)
face->UnitNormal(f_nrm); // Get the face normal
r1->Centroid(r1_cnt); // Get the barycenter of the cell
face->Centroid(f_cnt); // Get the barycenter of the face
Sparse::RowMerger & r = aut.GetMerger();
if( !r2->isValid() ) // boundary condition
{
Storage::real bnd_pnt[3], dist;
......
This diff is collapsed.
......@@ -1312,15 +1312,46 @@ namespace INMOST
}
void Clear()
{
ClearResidual();
ClearJacobian();
#if defined(USE_OMP)
#pragma omp for
#endif
for(int k = (int)GetFirstIndex(); k < (int)GetLastIndex(); ++k)
{
residual[k] = 0.0;
jacobian[k].Clear();
}
}
INMOST_DATA_REAL_TYPE Norm()
{
INMOST_DATA_REAL_TYPE ret = 0;
for(Sparse::Vector::iterator it = residual.Begin(); it != residual.End(); ++it) ret += (*it)*(*it);
#if defined(USE_OMP)
#pragma omp for
#endif
for(int k = (int)GetFirstIndex(); k < (int)GetLastIndex(); ++k)
ret += residual[k]*residual[k];
return sqrt(ret);
}
/// Normalize entries in jacobian and right hand side
void Rescale()
{
#if defined(USE_OMP)
#pragma omp for
#endif
for(int k = (int)GetFirstIndex(); k < (int)GetLastIndex(); ++k)
{
INMOST_DATA_REAL_TYPE norm = 0.0;
for(INMOST_DATA_ENUM_TYPE q = 0; q < jacobian[k].Size(); ++q)
norm += jacobian[k].GetValue(q)*jacobian[k].GetValue(q);
norm = sqrt(norm);
if( norm )
{
norm = 1.0/norm;
residual[k] *= norm;
for(INMOST_DATA_ENUM_TYPE q = 0; q < jacobian[k].Size(); ++q)
jacobian[k].GetValue(q) *= norm;
}
}
}
};
}
......
......@@ -12,10 +12,7 @@ namespace INMOST
#if defined(USE_AUTODIFF)
std::string VariableToString(INMOST::Storage::var v);
#endif
char * sstrip(char * str);
std::string sstrip(const std::string & input);
int ConvertHex(char in);
char atoc(const char * str);
class XMLReader
......
......@@ -7,7 +7,7 @@
namespace INMOST
{
int get_priority(char c)
static int get_priority(char c)
{
switch(c)
{
......@@ -22,14 +22,14 @@ namespace INMOST
}
}
int ConvertHex(char in)
static int ConvertHex(char in)
{
int ret = tolower(in) - 48;
if( ret > 10 ) ret -= 7;
if( ret > 15 ) ret -= 32;
return ret;
}
char atoc(const char * str)
static char atoc(const char * str)
{
return (char)(ConvertHex(str[0])*16 + ConvertHex(str[1]));
}
......@@ -62,7 +62,7 @@ namespace INMOST
}
#endif
char * sstrip(char * str)
static char * sstrip(char * str)
{
int text_start = 0, text_end = (int)strlen(str);
for(text_start = 0; isspace(str[text_start]) && text_start < text_end; text_start++);
......@@ -72,7 +72,7 @@ namespace INMOST
return str+text_start;
}
std::string sstrip(const std::string & input)
static std::string sstrip(const std::string & input)
{
char temp[2048];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment