Compare commits
59
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8b555a7bf8 | ||
|
|
fb0cdbb9f7 | ||
|
|
a8090e318d | ||
|
|
5896f590e7 | ||
|
|
cda68d779c | ||
|
|
d54d2668a2 | ||
|
|
1af666cb9a | ||
|
|
ad87b9cb5f | ||
|
|
1c037bf476 | ||
|
|
47e042245e | ||
|
|
4e25b1ba6b | ||
|
|
30a8a51e20 | ||
|
|
d9ae367705 | ||
|
|
b3a3ad3488 | ||
|
|
ceaabce20d | ||
|
|
49fe6fc429 | ||
|
|
1c1e8293e1 | ||
|
|
bcad115dda | ||
|
|
7c81683d1b | ||
|
|
7d1b07f873 | ||
|
|
80449bbd15 | ||
|
|
bf4c7ea8c1 | ||
|
|
9beaa836b0 | ||
|
|
b5670b4daf | ||
|
|
fd44d57e91 | ||
|
|
7d15a638be | ||
|
|
b273b7669f | ||
|
|
d983b34924 | ||
|
|
373a3a0099 | ||
|
|
aa4d4efc04 | ||
|
|
e9fbd5057f | ||
|
|
a4aa7d70b9 | ||
|
|
d96152a08a | ||
|
|
d41b97552c | ||
|
|
4db39d6d4b | ||
|
|
b3813ed053 | ||
|
|
b78275e79e | ||
|
|
a8c34e351e | ||
|
|
a3d2036838 | ||
|
|
f36873a150 | ||
|
|
e617238cc5 | ||
|
|
47e62a55f9 | ||
|
|
89f62d04e1 | ||
|
|
686756d73f | ||
|
|
a3e7080fc1 | ||
|
|
1911fbc883 | ||
|
|
36106d6fe4 | ||
|
|
eea5e91bb3 | ||
|
|
9eca33b09d | ||
|
|
b89222762d | ||
|
|
69e4e13185 | ||
|
|
c80fdc6f74 | ||
|
|
bada9b86f0 | ||
|
|
d02a90f9f2 | ||
|
|
9017b9700d | ||
|
|
3b4fc3b1df | ||
|
|
ee3a46af24 | ||
|
|
c64d7858e8 | ||
|
|
f106c03dd1 |
@@ -37,6 +37,9 @@ New and updated examples and miniapps
|
||||
|
||||
Miscellaneous
|
||||
-------------
|
||||
- Added support for single and double precision, with corresponding hypre build.
|
||||
Generalized the floating point type from `double` to `real_t`.
|
||||
|
||||
- The ReadCubit Genesis mesh importer has been rewritten to improve readability.
|
||||
|
||||
- Updated the Doxygen documentation style, which now requires Doxygen version
|
||||
|
||||
@@ -359,6 +359,8 @@ Before you can start, you need a GitHub account, here are a few suggestions:
|
||||
conflicted files in the commit message.
|
||||
- All significant new features and changes should be documented in CHANGELOG.
|
||||
- New examples and miniapps should have documentation on the MFEM webpage.
|
||||
- The general floating-point type `real_t` should be used, rather than
|
||||
`float` or `double`, except in special cases where only one is possible.
|
||||
|
||||
|
||||
### Pull Requests
|
||||
|
||||
@@ -63,6 +63,8 @@ set(MFEM_USE_ALGOIM @MFEM_USE_ALGOIM@)
|
||||
set(MFEM_USE_BENCHMARK @MFEM_USE_BENCHMARK@)
|
||||
set(MFEM_USE_PARELAG @MFEM_USE_PARELAG@)
|
||||
set(MFEM_USE_ENZYME @MFEM_USE_ENZYME@)
|
||||
set(MFEM_USE_DOUBLE @MFEM_USE_DOUBLE@)
|
||||
set(MFEM_USE_SINGLE @MFEM_USE_SINGLE@)
|
||||
|
||||
set(MFEM_CXX_COMPILER "@CMAKE_CXX_COMPILER@")
|
||||
set(MFEM_CXX_FLAGS "@CMAKE_CXX_FLAGS@")
|
||||
|
||||
@@ -201,4 +201,10 @@
|
||||
// Enable Enzyme for AD
|
||||
#cmakedefine MFEM_USE_ENZYME
|
||||
|
||||
// Use double-precision floating point type
|
||||
#cmakedefine MFEM_USE_DOUBLE
|
||||
|
||||
// Use single-precision floating point type
|
||||
#cmakedefine MFEM_USE_SINGLE
|
||||
|
||||
#endif // MFEM_CONFIG_HEADER
|
||||
|
||||
@@ -201,4 +201,10 @@
|
||||
// Enable the Enzyme LLVM plugin
|
||||
// #define MFEM_USE_ENZYME
|
||||
|
||||
// Use double-precision floating point type
|
||||
// #define MFEM_USE_DOUBLE
|
||||
|
||||
// Use single-precision floating point type
|
||||
// #define MFEM_USE_SINGLE
|
||||
|
||||
#endif // MFEM_CONFIG_HEADER
|
||||
|
||||
@@ -64,6 +64,8 @@ MFEM_USE_CODIPACK = @MFEM_USE_CODIPACK@
|
||||
MFEM_USE_BENCHMARK = @MFEM_USE_BENCHMARK@
|
||||
MFEM_USE_PARELAG = @MFEM_USE_PARELAG@
|
||||
MFEM_USE_ENZYME = @MFEM_USE_ENZYME@
|
||||
MFEM_USE_DOUBLE = @MFEM_USE_DOUBLE@
|
||||
MFEM_USE_SINGLE = @MFEM_USE_SINGLE@
|
||||
|
||||
# Compiler, compile options, and link options
|
||||
MFEM_CXX = @MFEM_CXX@
|
||||
|
||||
@@ -66,6 +66,8 @@ option(MFEM_USE_CODIPACK "Enable automatic differentiation (AD) using CoDiPack"
|
||||
option(MFEM_USE_BENCHMARK "Enable Google Benchmark" OFF)
|
||||
option(MFEM_USE_PARELAG "Enable ParELAG" OFF)
|
||||
option(MFEM_USE_ENZYME "Enable Enzyme" OFF)
|
||||
option(MFEM_USE_DOUBLE "Double precision" ON)
|
||||
option(MFEM_USE_SINGLE "Single precision" OFF)
|
||||
|
||||
# Optional overrides for autodetected MPIEXEC and MPIEXEC_NUMPROC_FLAG
|
||||
# set(MFEM_MPIEXEC "mpirun" CACHE STRING "Command for running MPI tests")
|
||||
|
||||
@@ -167,6 +167,8 @@ MFEM_USE_CODIPACK = NO
|
||||
MFEM_USE_BENCHMARK = NO
|
||||
MFEM_USE_PARELAG = NO
|
||||
MFEM_USE_ENZYME = NO
|
||||
MFEM_USE_DOUBLE = YES
|
||||
MFEM_USE_SINGLE = NO
|
||||
|
||||
# MPI library compile and link flags
|
||||
# These settings are used only when building MFEM with MPI + HIP
|
||||
|
||||
+34
-30
@@ -62,7 +62,7 @@ protected:
|
||||
|
||||
BilinearForm M, S;
|
||||
NonlinearForm H;
|
||||
double viscosity;
|
||||
real_t viscosity;
|
||||
HyperelasticModel *model;
|
||||
|
||||
CGSolver M_solver; // Krylov solver for inverting the mass matrix M
|
||||
@@ -84,16 +84,16 @@ protected:
|
||||
|
||||
public:
|
||||
HyperelasticOperator(FiniteElementSpace &f, Array<int> &ess_bdr,
|
||||
double visc, double mu, double K);
|
||||
real_t visc, real_t mu, real_t K);
|
||||
|
||||
/// Compute the right-hand side of the ODE system.
|
||||
virtual void Mult(const Vector &vx, Vector &dvx_dt) const;
|
||||
/** Solve the Backward-Euler equation: k = f(x + dt*k, t), for the unknown k.
|
||||
This is the only requirement for high-order SDIRK implicit integration.*/
|
||||
virtual void ImplicitSolve(const double dt, const Vector &x, Vector &k);
|
||||
virtual void ImplicitSolve(const real_t dt, const Vector &x, Vector &k);
|
||||
|
||||
double ElasticEnergy(const Vector &x) const;
|
||||
double KineticEnergy(const Vector &v) const;
|
||||
real_t ElasticEnergy(const Vector &x) const;
|
||||
real_t KineticEnergy(const Vector &v) const;
|
||||
void GetElasticEnergyDensity(const GridFunction &x, GridFunction &w) const;
|
||||
|
||||
virtual ~HyperelasticOperator();
|
||||
@@ -109,7 +109,7 @@ private:
|
||||
BilinearForm *M, *S;
|
||||
NonlinearForm *H;
|
||||
mutable SparseMatrix *Jacobian;
|
||||
double dt;
|
||||
real_t dt;
|
||||
const Vector *v, *x;
|
||||
mutable Vector w, z;
|
||||
|
||||
@@ -117,7 +117,7 @@ public:
|
||||
ReducedSystemOperator(BilinearForm *M_, BilinearForm *S_, NonlinearForm *H_);
|
||||
|
||||
/// Set current dt, v, x values - needed to compute action and Jacobian.
|
||||
void SetParameters(double dt_, const Vector *v_, const Vector *x_);
|
||||
void SetParameters(real_t dt_, const Vector *v_, const Vector *x_);
|
||||
|
||||
/// Compute y = H(x + dt (v + dt k)) + M k + S (v + dt k).
|
||||
virtual void Mult(const Vector &k, Vector &y) const;
|
||||
@@ -141,7 +141,7 @@ private:
|
||||
public:
|
||||
ElasticEnergyCoefficient(HyperelasticModel &m, const GridFunction &x_)
|
||||
: model(m), x(x_) { }
|
||||
virtual double Eval(ElementTransformation &T, const IntegrationPoint &ip);
|
||||
virtual real_t Eval(ElementTransformation &T, const IntegrationPoint &ip);
|
||||
virtual ~ElasticEnergyCoefficient() { }
|
||||
};
|
||||
|
||||
@@ -161,11 +161,11 @@ int main(int argc, char *argv[])
|
||||
int ref_levels = 2;
|
||||
int order = 2;
|
||||
int ode_solver_type = 3;
|
||||
double t_final = 300.0;
|
||||
double dt = 3.0;
|
||||
double visc = 1e-2;
|
||||
double mu = 0.25;
|
||||
double K = 5.0;
|
||||
real_t t_final = 300.0;
|
||||
real_t dt = 3.0;
|
||||
real_t visc = 1e-2;
|
||||
real_t mu = 0.25;
|
||||
real_t K = 5.0;
|
||||
bool visualization = true;
|
||||
int vis_steps = 1;
|
||||
|
||||
@@ -205,6 +205,10 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
args.PrintOptions(cout);
|
||||
|
||||
#ifdef MFEM_USE_SINGLE
|
||||
MFEM_ABORT("This example is not supported in single precision.");
|
||||
#endif
|
||||
|
||||
// 2. Read the mesh from the given mesh file. We can handle triangular,
|
||||
// quadrilateral, tetrahedral and hexahedral meshes with the same code.
|
||||
Mesh *mesh = new Mesh(mesh_file, 1, 1);
|
||||
@@ -309,13 +313,13 @@ int main(int argc, char *argv[])
|
||||
<< " Press space (in the GLVis window) to resume it.\n";
|
||||
}
|
||||
|
||||
double ee0 = oper.ElasticEnergy(x.GetTrueVector());
|
||||
double ke0 = oper.KineticEnergy(v.GetTrueVector());
|
||||
real_t ee0 = oper.ElasticEnergy(x.GetTrueVector());
|
||||
real_t ke0 = oper.KineticEnergy(v.GetTrueVector());
|
||||
cout << "initial elastic energy (EE) = " << ee0 << endl;
|
||||
cout << "initial kinetic energy (KE) = " << ke0 << endl;
|
||||
cout << "initial total energy (TE) = " << (ee0 + ke0) << endl;
|
||||
|
||||
double t = 0.0;
|
||||
real_t t = 0.0;
|
||||
oper.SetTime(t);
|
||||
ode_solver->Init(oper);
|
||||
|
||||
@@ -324,7 +328,7 @@ int main(int argc, char *argv[])
|
||||
bool last_step = false;
|
||||
for (int ti = 1; !last_step; ti++)
|
||||
{
|
||||
double dt_real = min(dt, t_final - t);
|
||||
real_t dt_real = min(dt, t_final - t);
|
||||
|
||||
ode_solver->Step(vx, t, dt_real);
|
||||
|
||||
@@ -332,8 +336,8 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (last_step || (ti % vis_steps) == 0)
|
||||
{
|
||||
double ee = oper.ElasticEnergy(x.GetTrueVector());
|
||||
double ke = oper.KineticEnergy(v.GetTrueVector());
|
||||
real_t ee = oper.ElasticEnergy(x.GetTrueVector());
|
||||
real_t ke = oper.KineticEnergy(v.GetTrueVector());
|
||||
|
||||
cout << "step " << ti << ", t = " << t << ", EE = " << ee << ", KE = "
|
||||
<< ke << ", ΔTE = " << (ee+ke)-(ee0+ke0) << endl;
|
||||
@@ -419,7 +423,7 @@ ReducedSystemOperator::ReducedSystemOperator(
|
||||
dt(0.0), v(NULL), x(NULL), w(height), z(height)
|
||||
{ }
|
||||
|
||||
void ReducedSystemOperator::SetParameters(double dt_, const Vector *v_,
|
||||
void ReducedSystemOperator::SetParameters(real_t dt_, const Vector *v_,
|
||||
const Vector *x_)
|
||||
{
|
||||
dt = dt_; v = v_; x = x_;
|
||||
@@ -453,16 +457,16 @@ ReducedSystemOperator::~ReducedSystemOperator()
|
||||
|
||||
|
||||
HyperelasticOperator::HyperelasticOperator(FiniteElementSpace &f,
|
||||
Array<int> &ess_bdr, double visc,
|
||||
double mu, double K)
|
||||
: TimeDependentOperator(2*f.GetTrueVSize(), 0.0), fespace(f),
|
||||
Array<int> &ess_bdr, real_t visc,
|
||||
real_t mu, real_t K)
|
||||
: TimeDependentOperator(2*f.GetTrueVSize(), (real_t) 0.0), fespace(f),
|
||||
M(&fespace), S(&fespace), H(&fespace),
|
||||
viscosity(visc), z(height/2)
|
||||
{
|
||||
const double rel_tol = 1e-8;
|
||||
const real_t rel_tol = 1e-8;
|
||||
const int skip_zero_entries = 0;
|
||||
|
||||
const double ref_density = 1.0; // density in the reference configuration
|
||||
const real_t ref_density = 1.0; // density in the reference configuration
|
||||
ConstantCoefficient rho0(ref_density);
|
||||
M.AddDomainIntegrator(new VectorMassIntegrator(rho0));
|
||||
M.Assemble(skip_zero_entries);
|
||||
@@ -533,7 +537,7 @@ void HyperelasticOperator::Mult(const Vector &vx, Vector &dvx_dt) const
|
||||
dx_dt = v;
|
||||
}
|
||||
|
||||
void HyperelasticOperator::ImplicitSolve(const double dt,
|
||||
void HyperelasticOperator::ImplicitSolve(const real_t dt,
|
||||
const Vector &vx, Vector &dvx_dt)
|
||||
{
|
||||
int sc = height/2;
|
||||
@@ -555,12 +559,12 @@ void HyperelasticOperator::ImplicitSolve(const double dt,
|
||||
add(v, dt, dv_dt, dx_dt);
|
||||
}
|
||||
|
||||
double HyperelasticOperator::ElasticEnergy(const Vector &x) const
|
||||
real_t HyperelasticOperator::ElasticEnergy(const Vector &x) const
|
||||
{
|
||||
return H.GetEnergy(x);
|
||||
}
|
||||
|
||||
double HyperelasticOperator::KineticEnergy(const Vector &v) const
|
||||
real_t HyperelasticOperator::KineticEnergy(const Vector &v) const
|
||||
{
|
||||
return 0.5*M.InnerProduct(v, v);
|
||||
}
|
||||
@@ -581,7 +585,7 @@ HyperelasticOperator::~HyperelasticOperator()
|
||||
}
|
||||
|
||||
|
||||
double ElasticEnergyCoefficient::Eval(ElementTransformation &T,
|
||||
real_t ElasticEnergyCoefficient::Eval(ElementTransformation &T,
|
||||
const IntegrationPoint &ip)
|
||||
{
|
||||
model.SetTransformation(T);
|
||||
@@ -601,7 +605,7 @@ void InitialDeformation(const Vector &x, Vector &y)
|
||||
void InitialVelocity(const Vector &x, Vector &v)
|
||||
{
|
||||
const int dim = x.Size();
|
||||
const double s = 0.1/64.;
|
||||
const real_t s = 0.1/64.;
|
||||
|
||||
v = 0.0;
|
||||
v(dim-1) = s*x(0)*x(0)*(8.0-x(0));
|
||||
|
||||
+38
-34
@@ -63,7 +63,7 @@ protected:
|
||||
|
||||
ParBilinearForm M, S;
|
||||
ParNonlinearForm H;
|
||||
double viscosity;
|
||||
real_t viscosity;
|
||||
HyperelasticModel *model;
|
||||
|
||||
HypreParMatrix *Mmat; // Mass matrix from ParallelAssemble()
|
||||
@@ -86,16 +86,16 @@ protected:
|
||||
|
||||
public:
|
||||
HyperelasticOperator(ParFiniteElementSpace &f, Array<int> &ess_bdr,
|
||||
double visc, double mu, double K);
|
||||
real_t visc, real_t mu, real_t K);
|
||||
|
||||
/// Compute the right-hand side of the ODE system.
|
||||
virtual void Mult(const Vector &vx, Vector &dvx_dt) const;
|
||||
/** Solve the Backward-Euler equation: k = f(x + dt*k, t), for the unknown k.
|
||||
This is the only requirement for high-order SDIRK implicit integration.*/
|
||||
virtual void ImplicitSolve(const double dt, const Vector &x, Vector &k);
|
||||
virtual void ImplicitSolve(const real_t dt, const Vector &x, Vector &k);
|
||||
|
||||
double ElasticEnergy(const ParGridFunction &x) const;
|
||||
double KineticEnergy(const ParGridFunction &v) const;
|
||||
real_t ElasticEnergy(const ParGridFunction &x) const;
|
||||
real_t KineticEnergy(const ParGridFunction &v) const;
|
||||
void GetElasticEnergyDensity(const ParGridFunction &x,
|
||||
ParGridFunction &w) const;
|
||||
|
||||
@@ -112,7 +112,7 @@ private:
|
||||
ParBilinearForm *M, *S;
|
||||
ParNonlinearForm *H;
|
||||
mutable HypreParMatrix *Jacobian;
|
||||
double dt;
|
||||
real_t dt;
|
||||
const Vector *v, *x;
|
||||
mutable Vector w, z;
|
||||
const Array<int> &ess_tdof_list;
|
||||
@@ -122,7 +122,7 @@ public:
|
||||
ParNonlinearForm *H_, const Array<int> &ess_tdof_list);
|
||||
|
||||
/// Set current dt, v, x values - needed to compute action and Jacobian.
|
||||
void SetParameters(double dt_, const Vector *v_, const Vector *x_);
|
||||
void SetParameters(real_t dt_, const Vector *v_, const Vector *x_);
|
||||
|
||||
/// Compute y = H(x + dt (v + dt k)) + M k + S (v + dt k).
|
||||
virtual void Mult(const Vector &k, Vector &y) const;
|
||||
@@ -146,7 +146,7 @@ private:
|
||||
public:
|
||||
ElasticEnergyCoefficient(HyperelasticModel &m, const ParGridFunction &x_)
|
||||
: model(m), x(x_) { }
|
||||
virtual double Eval(ElementTransformation &T, const IntegrationPoint &ip);
|
||||
virtual real_t Eval(ElementTransformation &T, const IntegrationPoint &ip);
|
||||
virtual ~ElasticEnergyCoefficient() { }
|
||||
};
|
||||
|
||||
@@ -173,11 +173,11 @@ int main(int argc, char *argv[])
|
||||
int par_ref_levels = 0;
|
||||
int order = 2;
|
||||
int ode_solver_type = 3;
|
||||
double t_final = 300.0;
|
||||
double dt = 3.0;
|
||||
double visc = 1e-2;
|
||||
double mu = 0.25;
|
||||
double K = 5.0;
|
||||
real_t t_final = 300.0;
|
||||
real_t dt = 3.0;
|
||||
real_t visc = 1e-2;
|
||||
real_t mu = 0.25;
|
||||
real_t K = 5.0;
|
||||
bool adaptive_lin_rtol = true;
|
||||
bool visualization = true;
|
||||
int vis_steps = 1;
|
||||
@@ -229,6 +229,10 @@ int main(int argc, char *argv[])
|
||||
args.PrintOptions(cout);
|
||||
}
|
||||
|
||||
#ifdef MFEM_USE_SINGLE
|
||||
MFEM_ABORT("This example is not supported in single precision.");
|
||||
#endif
|
||||
|
||||
// 3. Read the serial mesh from the given mesh file on all processors. We can
|
||||
// handle triangular, quadrilateral, tetrahedral and hexahedral meshes
|
||||
// with the same code.
|
||||
@@ -358,8 +362,8 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
double ee0 = oper.ElasticEnergy(x_gf);
|
||||
double ke0 = oper.KineticEnergy(v_gf);
|
||||
real_t ee0 = oper.ElasticEnergy(x_gf);
|
||||
real_t ke0 = oper.KineticEnergy(v_gf);
|
||||
if (myid == 0)
|
||||
{
|
||||
cout << "initial elastic energy (EE) = " << ee0 << endl;
|
||||
@@ -367,7 +371,7 @@ int main(int argc, char *argv[])
|
||||
cout << "initial total energy (TE) = " << (ee0 + ke0) << endl;
|
||||
}
|
||||
|
||||
double t = 0.0;
|
||||
real_t t = 0.0;
|
||||
oper.SetTime(t);
|
||||
ode_solver->Init(oper);
|
||||
|
||||
@@ -376,7 +380,7 @@ int main(int argc, char *argv[])
|
||||
bool last_step = false;
|
||||
for (int ti = 1; !last_step; ti++)
|
||||
{
|
||||
double dt_real = min(dt, t_final - t);
|
||||
real_t dt_real = min(dt, t_final - t);
|
||||
|
||||
ode_solver->Step(vx, t, dt_real);
|
||||
|
||||
@@ -386,8 +390,8 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
v_gf.SetFromTrueVector(); x_gf.SetFromTrueVector();
|
||||
|
||||
double ee = oper.ElasticEnergy(x_gf);
|
||||
double ke = oper.KineticEnergy(v_gf);
|
||||
real_t ee = oper.ElasticEnergy(x_gf);
|
||||
real_t ke = oper.KineticEnergy(v_gf);
|
||||
|
||||
if (myid == 0)
|
||||
{
|
||||
@@ -485,7 +489,7 @@ ReducedSystemOperator::ReducedSystemOperator(
|
||||
ess_tdof_list(ess_tdof_list_)
|
||||
{ }
|
||||
|
||||
void ReducedSystemOperator::SetParameters(double dt_, const Vector *v_,
|
||||
void ReducedSystemOperator::SetParameters(real_t dt_, const Vector *v_,
|
||||
const Vector *x_)
|
||||
{
|
||||
dt = dt_; v = v_; x = x_;
|
||||
@@ -523,17 +527,17 @@ ReducedSystemOperator::~ReducedSystemOperator()
|
||||
|
||||
|
||||
HyperelasticOperator::HyperelasticOperator(ParFiniteElementSpace &f,
|
||||
Array<int> &ess_bdr, double visc,
|
||||
double mu, double K)
|
||||
: TimeDependentOperator(2*f.TrueVSize(), 0.0), fespace(f),
|
||||
Array<int> &ess_bdr, real_t visc,
|
||||
real_t mu, real_t K)
|
||||
: TimeDependentOperator(2*f.TrueVSize(), (real_t) 0.0), fespace(f),
|
||||
M(&fespace), S(&fespace), H(&fespace),
|
||||
viscosity(visc), M_solver(f.GetComm()), newton_solver(f.GetComm()),
|
||||
z(height/2)
|
||||
{
|
||||
const double rel_tol = 1e-8;
|
||||
const real_t rel_tol = 1e-8;
|
||||
const int skip_zero_entries = 0;
|
||||
|
||||
const double ref_density = 1.0; // density in the reference configuration
|
||||
const real_t ref_density = 1.0; // density in the reference configuration
|
||||
ConstantCoefficient rho0(ref_density);
|
||||
M.AddDomainIntegrator(new VectorMassIntegrator(rho0));
|
||||
M.Assemble(skip_zero_entries);
|
||||
@@ -607,7 +611,7 @@ void HyperelasticOperator::Mult(const Vector &vx, Vector &dvx_dt) const
|
||||
dx_dt = v;
|
||||
}
|
||||
|
||||
void HyperelasticOperator::ImplicitSolve(const double dt,
|
||||
void HyperelasticOperator::ImplicitSolve(const real_t dt,
|
||||
const Vector &vx, Vector &dvx_dt)
|
||||
{
|
||||
int sc = height/2;
|
||||
@@ -629,17 +633,17 @@ void HyperelasticOperator::ImplicitSolve(const double dt,
|
||||
add(v, dt, dv_dt, dx_dt);
|
||||
}
|
||||
|
||||
double HyperelasticOperator::ElasticEnergy(const ParGridFunction &x) const
|
||||
real_t HyperelasticOperator::ElasticEnergy(const ParGridFunction &x) const
|
||||
{
|
||||
return H.GetEnergy(x);
|
||||
}
|
||||
|
||||
double HyperelasticOperator::KineticEnergy(const ParGridFunction &v) const
|
||||
real_t HyperelasticOperator::KineticEnergy(const ParGridFunction &v) const
|
||||
{
|
||||
double loc_energy = 0.5*M.InnerProduct(v, v);
|
||||
double energy;
|
||||
MPI_Allreduce(&loc_energy, &energy, 1, MPI_DOUBLE, MPI_SUM,
|
||||
fespace.GetComm());
|
||||
real_t loc_energy = 0.5*M.InnerProduct(v, v);
|
||||
real_t energy;
|
||||
MPI_Allreduce(&loc_energy, &energy, 1, MPITypeMap<real_t>::mpi_type,
|
||||
MPI_SUM, fespace.GetComm());
|
||||
return energy;
|
||||
}
|
||||
|
||||
@@ -660,7 +664,7 @@ HyperelasticOperator::~HyperelasticOperator()
|
||||
}
|
||||
|
||||
|
||||
double ElasticEnergyCoefficient::Eval(ElementTransformation &T,
|
||||
real_t ElasticEnergyCoefficient::Eval(ElementTransformation &T,
|
||||
const IntegrationPoint &ip)
|
||||
{
|
||||
model.SetTransformation(T);
|
||||
@@ -680,7 +684,7 @@ void InitialDeformation(const Vector &x, Vector &y)
|
||||
void InitialVelocity(const Vector &x, Vector &v)
|
||||
{
|
||||
const int dim = x.Size();
|
||||
const double s = 0.1/64.;
|
||||
const real_t s = 0.1/64.;
|
||||
|
||||
v = 0.0;
|
||||
v(dim-1) = s*x(0)*x(0)*(8.0-x(0));
|
||||
|
||||
+2
-2
@@ -211,7 +211,7 @@ int main(int argc, char *argv[])
|
||||
m->AddDomainIntegrator(new MassIntegrator(one));
|
||||
m->Assemble();
|
||||
// shift the eigenvalue corresponding to eliminated dofs to a large value
|
||||
m->EliminateEssentialBCDiag(ess_bdr, numeric_limits<double>::min());
|
||||
m->EliminateEssentialBCDiag(ess_bdr, numeric_limits<real_t>::min());
|
||||
m->Finalize();
|
||||
|
||||
HypreParMatrix *A = a->ParallelAssemble();
|
||||
@@ -300,7 +300,7 @@ int main(int argc, char *argv[])
|
||||
// 9. Compute the eigenmodes and extract the array of eigenvalues. Define a
|
||||
// parallel grid function to represent each of the eigenmodes returned by
|
||||
// the solver.
|
||||
Array<double> eigenvalues;
|
||||
Array<real_t> eigenvalues;
|
||||
lobpcg->Solve();
|
||||
lobpcg->GetEigenvalues(eigenvalues);
|
||||
ParGridFunction x(fespace);
|
||||
|
||||
+2
-2
@@ -206,7 +206,7 @@ int main(int argc, char *argv[])
|
||||
m->AddDomainIntegrator(new VectorMassIntegrator());
|
||||
m->Assemble();
|
||||
// shift the eigenvalue corresponding to eliminated dofs to a large value
|
||||
m->EliminateEssentialBCDiag(ess_bdr, numeric_limits<double>::min());
|
||||
m->EliminateEssentialBCDiag(ess_bdr, numeric_limits<real_t>::min());
|
||||
m->Finalize();
|
||||
if (myid == 0)
|
||||
{
|
||||
@@ -247,7 +247,7 @@ int main(int argc, char *argv[])
|
||||
// 10. Compute the eigenmodes and extract the array of eigenvalues. Define a
|
||||
// parallel grid function to represent each of the eigenmodes returned by
|
||||
// the solver.
|
||||
Array<double> eigenvalues;
|
||||
Array<real_t> eigenvalues;
|
||||
lobpcg->Solve();
|
||||
lobpcg->GetEigenvalues(eigenvalues);
|
||||
ParGridFunction x(fespace);
|
||||
|
||||
+2
-2
@@ -170,7 +170,7 @@ int main(int argc, char *argv[])
|
||||
m->AddDomainIntegrator(new VectorFEMassIntegrator(one));
|
||||
m->Assemble();
|
||||
// shift the eigenvalue corresponding to eliminated dofs to a large value
|
||||
m->EliminateEssentialBCDiag(ess_bdr, numeric_limits<double>::min());
|
||||
m->EliminateEssentialBCDiag(ess_bdr, numeric_limits<real_t>::min());
|
||||
m->Finalize();
|
||||
|
||||
HypreParMatrix *A = a->ParallelAssemble();
|
||||
@@ -198,7 +198,7 @@ int main(int argc, char *argv[])
|
||||
// 10. Compute the eigenmodes and extract the array of eigenvalues. Define a
|
||||
// parallel grid function to represent each of the eigenmodes returned by
|
||||
// the solver.
|
||||
Array<double> eigenvalues;
|
||||
Array<real_t> eigenvalues;
|
||||
ame->Solve();
|
||||
ame->GetEigenvalues(eigenvalues);
|
||||
ParGridFunction x(fespace);
|
||||
|
||||
+3
-3
@@ -43,9 +43,9 @@ int main(int argc, char *argv[])
|
||||
const char *mesh_file = "../data/star.mesh";
|
||||
int ref_levels = -1;
|
||||
int order = 1;
|
||||
double sigma = -1.0;
|
||||
double kappa = -1.0;
|
||||
double eta = 0.0;
|
||||
real_t sigma = -1.0;
|
||||
real_t kappa = -1.0;
|
||||
real_t eta = 0.0;
|
||||
bool visualization = 1;
|
||||
|
||||
OptionsParser args(argc, argv);
|
||||
|
||||
+4
-4
@@ -44,7 +44,7 @@ public:
|
||||
pmesh(m),
|
||||
pgf(f) {}
|
||||
|
||||
void MonitorSolution(int i, double norm, const Vector &x, bool final)
|
||||
void MonitorSolution(int i, real_t norm, const Vector &x, bool final)
|
||||
{
|
||||
char vishost[] = "localhost";
|
||||
int visport = 19916;
|
||||
@@ -81,9 +81,9 @@ int main(int argc, char *argv[])
|
||||
int ser_ref_levels = -1;
|
||||
int par_ref_levels = 2;
|
||||
int order = 1;
|
||||
double sigma = -1.0;
|
||||
double kappa = -1.0;
|
||||
double eta = 0.0;
|
||||
real_t sigma = -1.0;
|
||||
real_t kappa = -1.0;
|
||||
real_t eta = 0.0;
|
||||
bool visualization = 1;
|
||||
|
||||
OptionsParser args(argc, argv);
|
||||
|
||||
+30
-30
@@ -63,8 +63,8 @@ int problem;
|
||||
int nfeatures;
|
||||
|
||||
// Prescribed time-dependent boundary and right-hand side functions.
|
||||
double bdr_func(const Vector &pt, double t);
|
||||
double rhs_func(const Vector &pt, double t);
|
||||
real_t bdr_func(const Vector &pt, real_t t);
|
||||
real_t rhs_func(const Vector &pt, real_t t);
|
||||
|
||||
// Update the finite element space, interpolate the solution and perform
|
||||
// parallel load balancing.
|
||||
@@ -79,9 +79,9 @@ int main(int argc, char *argv[])
|
||||
nfeatures = 1;
|
||||
const char *mesh_file = "../data/star-hilbert.mesh";
|
||||
int order = 2;
|
||||
double t_final = 1.0;
|
||||
double max_elem_error = 5.0e-3;
|
||||
double hysteresis = 0.15; // derefinement safety coefficient
|
||||
real_t t_final = 1.0;
|
||||
real_t max_elem_error = 5.0e-3;
|
||||
real_t hysteresis = 0.15; // derefinement safety coefficient
|
||||
int ref_levels = 0;
|
||||
int nc_limit = 3; // maximum level of hanging nodes
|
||||
bool visualization = true;
|
||||
@@ -247,7 +247,7 @@ int main(int argc, char *argv[])
|
||||
// refine the mesh as many times as necessary. Then we derefine any
|
||||
// elements which have very small errors.
|
||||
x = 0.0;
|
||||
for (double time = 0.0; time < t_final + 1e-10; time += 0.01)
|
||||
for (real_t time = 0.0; time < t_final + 1e-10; time += 0.01)
|
||||
{
|
||||
cout << "\nTime " << time << "\n\nRefinement:" << endl;
|
||||
|
||||
@@ -366,47 +366,47 @@ void UpdateProblem(Mesh &mesh, FiniteElementSpace &fespace,
|
||||
}
|
||||
|
||||
|
||||
const double alpha = 0.02;
|
||||
const real_t alpha = 0.02;
|
||||
|
||||
// Spherical front with a Gaussian cross section and radius t
|
||||
double front(double x, double y, double z, double t, int)
|
||||
real_t front(real_t x, real_t y, real_t z, real_t t, int)
|
||||
{
|
||||
double r = sqrt(x*x + y*y + z*z);
|
||||
real_t r = sqrt(x*x + y*y + z*z);
|
||||
return exp(-0.5*pow((r - t)/alpha, 2));
|
||||
}
|
||||
|
||||
double front_laplace(double x, double y, double z, double t, int dim)
|
||||
real_t front_laplace(real_t x, real_t y, real_t z, real_t t, int dim)
|
||||
{
|
||||
double x2 = x*x, y2 = y*y, z2 = z*z, t2 = t*t;
|
||||
double r = sqrt(x2 + y2 + z2);
|
||||
double a2 = alpha*alpha, a4 = a2*a2;
|
||||
real_t x2 = x*x, y2 = y*y, z2 = z*z, t2 = t*t;
|
||||
real_t r = sqrt(x2 + y2 + z2);
|
||||
real_t a2 = alpha*alpha, a4 = a2*a2;
|
||||
return -exp(-0.5*pow((r - t)/alpha, 2)) / a4 *
|
||||
(-2*t*(x2 + y2 + z2 - (dim-1)*a2/2)/r + x2 + y2 + z2 + t2 - dim*a2);
|
||||
}
|
||||
|
||||
// Smooth spherical step function with radius t
|
||||
double ball(double x, double y, double z, double t, int)
|
||||
real_t ball(real_t x, real_t y, real_t z, real_t t, int)
|
||||
{
|
||||
double r = sqrt(x*x + y*y + z*z);
|
||||
real_t r = sqrt(x*x + y*y + z*z);
|
||||
return -atan(2*(r - t)/alpha);
|
||||
}
|
||||
|
||||
double ball_laplace(double x, double y, double z, double t, int dim)
|
||||
real_t ball_laplace(real_t x, real_t y, real_t z, real_t t, int dim)
|
||||
{
|
||||
double x2 = x*x, y2 = y*y, z2 = z*z, t2 = 4*t*t;
|
||||
double r = sqrt(x2 + y2 + z2);
|
||||
double a2 = alpha*alpha;
|
||||
double den = pow(-a2 - 4*(x2 + y2 + z2 - 2*r*t) - t2, 2.0);
|
||||
real_t x2 = x*x, y2 = y*y, z2 = z*z, t2 = 4*t*t;
|
||||
real_t r = sqrt(x2 + y2 + z2);
|
||||
real_t a2 = alpha*alpha;
|
||||
real_t den = pow(-a2 - 4*(x2 + y2 + z2 - 2*r*t) - t2, 2.0);
|
||||
return (dim == 2) ? 2*alpha*(a2 + t2 - 4*x2 - 4*y2)/r/den
|
||||
/* */ : 4*alpha*(a2 + t2 - 4*r*t)/r/den;
|
||||
}
|
||||
|
||||
// Composes several features into one function
|
||||
template<typename F0, typename F1>
|
||||
double composite_func(const Vector &pt, double t, F0 f0, F1 f1)
|
||||
real_t composite_func(const Vector &pt, real_t t, F0 f0, F1 f1)
|
||||
{
|
||||
int dim = pt.Size();
|
||||
double x = pt(0), y = pt(1), z = 0.0;
|
||||
real_t x = pt(0), y = pt(1), z = 0.0;
|
||||
if (dim == 3) { z = pt(2); }
|
||||
|
||||
if (problem == 0)
|
||||
@@ -417,11 +417,11 @@ double composite_func(const Vector &pt, double t, F0 f0, F1 f1)
|
||||
}
|
||||
else
|
||||
{
|
||||
double sum = 0.0;
|
||||
real_t sum = 0.0;
|
||||
for (int i = 0; i < nfeatures; i++)
|
||||
{
|
||||
double x0 = 0.5*cos(2*M_PI * i / nfeatures);
|
||||
double y0 = 0.5*sin(2*M_PI * i / nfeatures);
|
||||
real_t x0 = 0.5*cos(2*M_PI * i / nfeatures);
|
||||
real_t y0 = 0.5*sin(2*M_PI * i / nfeatures);
|
||||
sum += f0(x - x0, y - y0, z, t, dim);
|
||||
}
|
||||
return sum;
|
||||
@@ -429,11 +429,11 @@ double composite_func(const Vector &pt, double t, F0 f0, F1 f1)
|
||||
}
|
||||
else
|
||||
{
|
||||
double sum = 0.0;
|
||||
real_t sum = 0.0;
|
||||
for (int i = 0; i < nfeatures; i++)
|
||||
{
|
||||
double x0 = 0.5*cos(2*M_PI * i / nfeatures + M_PI*t);
|
||||
double y0 = 0.5*sin(2*M_PI * i / nfeatures + M_PI*t);
|
||||
real_t x0 = 0.5*cos(2*M_PI * i / nfeatures + M_PI*t);
|
||||
real_t y0 = 0.5*sin(2*M_PI * i / nfeatures + M_PI*t);
|
||||
sum += f1(x - x0, y - y0, z, 0.25, dim);
|
||||
}
|
||||
return sum;
|
||||
@@ -441,13 +441,13 @@ double composite_func(const Vector &pt, double t, F0 f0, F1 f1)
|
||||
}
|
||||
|
||||
// Exact solution, used for the Dirichlet BC.
|
||||
double bdr_func(const Vector &pt, double t)
|
||||
real_t bdr_func(const Vector &pt, real_t t)
|
||||
{
|
||||
return composite_func(pt, t, front, ball);
|
||||
}
|
||||
|
||||
// Laplace of the exact solution, used for the right hand side.
|
||||
double rhs_func(const Vector &pt, double t)
|
||||
real_t rhs_func(const Vector &pt, real_t t)
|
||||
{
|
||||
return composite_func(pt, t, front_laplace, ball_laplace);
|
||||
}
|
||||
|
||||
+30
-30
@@ -68,8 +68,8 @@ int problem;
|
||||
int nfeatures;
|
||||
|
||||
// Prescribed time-dependent boundary and right-hand side functions.
|
||||
double bdr_func(const Vector &pt, double t);
|
||||
double rhs_func(const Vector &pt, double t);
|
||||
real_t bdr_func(const Vector &pt, real_t t);
|
||||
real_t rhs_func(const Vector &pt, real_t t);
|
||||
|
||||
// Update the finite element space, interpolate the solution and perform
|
||||
// parallel load balancing.
|
||||
@@ -91,9 +91,9 @@ int main(int argc, char *argv[])
|
||||
nfeatures = 1;
|
||||
const char *mesh_file = "../data/star-hilbert.mesh";
|
||||
int order = 2;
|
||||
double t_final = 1.0;
|
||||
double max_elem_error = 1.0e-4;
|
||||
double hysteresis = 0.25; // derefinement safety coefficient
|
||||
real_t t_final = 1.0;
|
||||
real_t max_elem_error = 1.0e-4;
|
||||
real_t hysteresis = 0.25; // derefinement safety coefficient
|
||||
int ref_levels = 0;
|
||||
int nc_limit = 3; // maximum level of hanging nodes
|
||||
bool visualization = true;
|
||||
@@ -282,7 +282,7 @@ int main(int argc, char *argv[])
|
||||
// solve the problem on the current mesh, visualize the solution and
|
||||
// refine the mesh as many times as necessary. Then we derefine any
|
||||
// elements which have very small errors.
|
||||
for (double time = 0.0; time < t_final + 1e-10; time += 0.01)
|
||||
for (real_t time = 0.0; time < t_final + 1e-10; time += 0.01)
|
||||
{
|
||||
if (myid == 0)
|
||||
{
|
||||
@@ -427,47 +427,47 @@ void UpdateAndRebalance(ParMesh &pmesh, ParFiniteElementSpace &fespace,
|
||||
}
|
||||
|
||||
|
||||
const double alpha = 0.02;
|
||||
const real_t alpha = 0.02;
|
||||
|
||||
// Spherical front with a Gaussian cross section and radius t
|
||||
double front(double x, double y, double z, double t, int)
|
||||
real_t front(real_t x, real_t y, real_t z, real_t t, int)
|
||||
{
|
||||
double r = sqrt(x*x + y*y + z*z);
|
||||
real_t r = sqrt(x*x + y*y + z*z);
|
||||
return exp(-0.5*pow((r - t)/alpha, 2));
|
||||
}
|
||||
|
||||
double front_laplace(double x, double y, double z, double t, int dim)
|
||||
real_t front_laplace(real_t x, real_t y, real_t z, real_t t, int dim)
|
||||
{
|
||||
double x2 = x*x, y2 = y*y, z2 = z*z, t2 = t*t;
|
||||
double r = sqrt(x2 + y2 + z2);
|
||||
double a2 = alpha*alpha, a4 = a2*a2;
|
||||
real_t x2 = x*x, y2 = y*y, z2 = z*z, t2 = t*t;
|
||||
real_t r = sqrt(x2 + y2 + z2);
|
||||
real_t a2 = alpha*alpha, a4 = a2*a2;
|
||||
return -exp(-0.5*pow((r - t)/alpha, 2)) / a4 *
|
||||
(-2*t*(x2 + y2 + z2 - (dim-1)*a2/2)/r + x2 + y2 + z2 + t2 - dim*a2);
|
||||
}
|
||||
|
||||
// Smooth spherical step function with radius t
|
||||
double ball(double x, double y, double z, double t, int)
|
||||
real_t ball(real_t x, real_t y, real_t z, real_t t, int)
|
||||
{
|
||||
double r = sqrt(x*x + y*y + z*z);
|
||||
real_t r = sqrt(x*x + y*y + z*z);
|
||||
return -atan(2*(r - t)/alpha);
|
||||
}
|
||||
|
||||
double ball_laplace(double x, double y, double z, double t, int dim)
|
||||
real_t ball_laplace(real_t x, real_t y, real_t z, real_t t, int dim)
|
||||
{
|
||||
double x2 = x*x, y2 = y*y, z2 = z*z, t2 = 4*t*t;
|
||||
double r = sqrt(x2 + y2 + z2);
|
||||
double a2 = alpha*alpha;
|
||||
double den = pow(-a2 - 4*(x2 + y2 + z2 - 2*r*t) - t2, 2.0);
|
||||
real_t x2 = x*x, y2 = y*y, z2 = z*z, t2 = 4*t*t;
|
||||
real_t r = sqrt(x2 + y2 + z2);
|
||||
real_t a2 = alpha*alpha;
|
||||
real_t den = pow(-a2 - 4*(x2 + y2 + z2 - 2*r*t) - t2, 2.0);
|
||||
return (dim == 2) ? 2*alpha*(a2 + t2 - 4*x2 - 4*y2)/r/den
|
||||
/* */ : 4*alpha*(a2 + t2 - 4*r*t)/r/den;
|
||||
}
|
||||
|
||||
// Composes several features into one function
|
||||
template<typename F0, typename F1>
|
||||
double composite_func(const Vector &pt, double t, F0 f0, F1 f1)
|
||||
real_t composite_func(const Vector &pt, real_t t, F0 f0, F1 f1)
|
||||
{
|
||||
int dim = pt.Size();
|
||||
double x = pt(0), y = pt(1), z = 0.0;
|
||||
real_t x = pt(0), y = pt(1), z = 0.0;
|
||||
if (dim == 3) { z = pt(2); }
|
||||
|
||||
if (problem == 0)
|
||||
@@ -478,11 +478,11 @@ double composite_func(const Vector &pt, double t, F0 f0, F1 f1)
|
||||
}
|
||||
else
|
||||
{
|
||||
double sum = 0.0;
|
||||
real_t sum = 0.0;
|
||||
for (int i = 0; i < nfeatures; i++)
|
||||
{
|
||||
double x0 = 0.5*cos(2*M_PI * i / nfeatures);
|
||||
double y0 = 0.5*sin(2*M_PI * i / nfeatures);
|
||||
real_t x0 = 0.5*cos(2*M_PI * i / nfeatures);
|
||||
real_t y0 = 0.5*sin(2*M_PI * i / nfeatures);
|
||||
sum += f0(x - x0, y - y0, z, t, dim);
|
||||
}
|
||||
return sum;
|
||||
@@ -490,11 +490,11 @@ double composite_func(const Vector &pt, double t, F0 f0, F1 f1)
|
||||
}
|
||||
else
|
||||
{
|
||||
double sum = 0.0;
|
||||
real_t sum = 0.0;
|
||||
for (int i = 0; i < nfeatures; i++)
|
||||
{
|
||||
double x0 = 0.5*cos(2*M_PI * i / nfeatures + M_PI*t);
|
||||
double y0 = 0.5*sin(2*M_PI * i / nfeatures + M_PI*t);
|
||||
real_t x0 = 0.5*cos(2*M_PI * i / nfeatures + M_PI*t);
|
||||
real_t y0 = 0.5*sin(2*M_PI * i / nfeatures + M_PI*t);
|
||||
sum += f1(x - x0, y - y0, z, 0.25, dim);
|
||||
}
|
||||
return sum;
|
||||
@@ -502,13 +502,13 @@ double composite_func(const Vector &pt, double t, F0 f0, F1 f1)
|
||||
}
|
||||
|
||||
// Exact solution, used for the Dirichlet BC.
|
||||
double bdr_func(const Vector &pt, double t)
|
||||
real_t bdr_func(const Vector &pt, real_t t)
|
||||
{
|
||||
return composite_func(pt, t, front, ball);
|
||||
}
|
||||
|
||||
// Laplace of the exact solution, used for the right hand side.
|
||||
double rhs_func(const Vector &pt, double t)
|
||||
real_t rhs_func(const Vector &pt, real_t t)
|
||||
{
|
||||
return composite_func(pt, t, front_laplace, ball_laplace);
|
||||
}
|
||||
|
||||
+17
-17
@@ -60,7 +60,7 @@ protected:
|
||||
|
||||
SparseMatrix Mmat, Kmat;
|
||||
SparseMatrix *T; // T = M + dt K
|
||||
double current_dt;
|
||||
real_t current_dt;
|
||||
|
||||
CGSolver M_solver; // Krylov solver for inverting the mass matrix M
|
||||
DSmoother M_prec; // Preconditioner for the mass matrix M
|
||||
@@ -68,18 +68,18 @@ protected:
|
||||
CGSolver T_solver; // Implicit solver for T = M + dt K
|
||||
DSmoother T_prec; // Preconditioner for the implicit solver
|
||||
|
||||
double alpha, kappa;
|
||||
real_t alpha, kappa;
|
||||
|
||||
mutable Vector z; // auxiliary vector
|
||||
|
||||
public:
|
||||
ConductionOperator(FiniteElementSpace &f, double alpha, double kappa,
|
||||
ConductionOperator(FiniteElementSpace &f, real_t alpha, real_t kappa,
|
||||
const Vector &u);
|
||||
|
||||
virtual void Mult(const Vector &u, Vector &du_dt) const;
|
||||
/** Solve the Backward-Euler equation: k = f(u + dt*k, t), for the unknown k.
|
||||
This is the only requirement for high-order SDIRK implicit integration.*/
|
||||
virtual void ImplicitSolve(const double dt, const Vector &u, Vector &k);
|
||||
virtual void ImplicitSolve(const real_t dt, const Vector &u, Vector &k);
|
||||
|
||||
/// Update the diffusion BilinearForm K using the given true-dof vector `u`.
|
||||
void SetParameters(const Vector &u);
|
||||
@@ -87,7 +87,7 @@ public:
|
||||
virtual ~ConductionOperator();
|
||||
};
|
||||
|
||||
double InitialTemperature(const Vector &x);
|
||||
real_t InitialTemperature(const Vector &x);
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
@@ -96,10 +96,10 @@ int main(int argc, char *argv[])
|
||||
int ref_levels = 2;
|
||||
int order = 2;
|
||||
int ode_solver_type = 3;
|
||||
double t_final = 0.5;
|
||||
double dt = 1.0e-2;
|
||||
double alpha = 1.0e-2;
|
||||
double kappa = 0.5;
|
||||
real_t t_final = 0.5;
|
||||
real_t dt = 1.0e-2;
|
||||
real_t alpha = 1.0e-2;
|
||||
real_t kappa = 0.5;
|
||||
bool visualization = true;
|
||||
bool visit = false;
|
||||
int vis_steps = 5;
|
||||
@@ -246,7 +246,7 @@ int main(int argc, char *argv[])
|
||||
// 8. Perform time-integration (looping over the time iterations, ti, with a
|
||||
// time-step dt).
|
||||
ode_solver->Init(oper);
|
||||
double t = 0.0;
|
||||
real_t t = 0.0;
|
||||
|
||||
bool last_step = false;
|
||||
for (int ti = 1; !last_step; ti++)
|
||||
@@ -293,12 +293,12 @@ int main(int argc, char *argv[])
|
||||
return 0;
|
||||
}
|
||||
|
||||
ConductionOperator::ConductionOperator(FiniteElementSpace &f, double al,
|
||||
double kap, const Vector &u)
|
||||
: TimeDependentOperator(f.GetTrueVSize(), 0.0), fespace(f), M(NULL), K(NULL),
|
||||
T(NULL), current_dt(0.0), z(height)
|
||||
ConductionOperator::ConductionOperator(FiniteElementSpace &f, real_t al,
|
||||
real_t kap, const Vector &u)
|
||||
: TimeDependentOperator(f.GetTrueVSize(), (real_t) 0.0), fespace(f),
|
||||
M(NULL), K(NULL), T(NULL), current_dt(0.0), z(height)
|
||||
{
|
||||
const double rel_tol = 1e-8;
|
||||
const real_t rel_tol = 1e-8;
|
||||
|
||||
M = new BilinearForm(&fespace);
|
||||
M->AddDomainIntegrator(new MassIntegrator());
|
||||
@@ -336,7 +336,7 @@ void ConductionOperator::Mult(const Vector &u, Vector &du_dt) const
|
||||
M_solver.Mult(z, du_dt);
|
||||
}
|
||||
|
||||
void ConductionOperator::ImplicitSolve(const double dt,
|
||||
void ConductionOperator::ImplicitSolve(const real_t dt,
|
||||
const Vector &u, Vector &du_dt)
|
||||
{
|
||||
// Solve the equation:
|
||||
@@ -382,7 +382,7 @@ ConductionOperator::~ConductionOperator()
|
||||
delete K;
|
||||
}
|
||||
|
||||
double InitialTemperature(const Vector &x)
|
||||
real_t InitialTemperature(const Vector &x)
|
||||
{
|
||||
if (x.Norml2() < 0.5)
|
||||
{
|
||||
|
||||
+17
-17
@@ -62,7 +62,7 @@ protected:
|
||||
HypreParMatrix Mmat;
|
||||
HypreParMatrix Kmat;
|
||||
HypreParMatrix *T; // T = M + dt K
|
||||
double current_dt;
|
||||
real_t current_dt;
|
||||
|
||||
CGSolver M_solver; // Krylov solver for inverting the mass matrix M
|
||||
HypreSmoother M_prec; // Preconditioner for the mass matrix M
|
||||
@@ -70,18 +70,18 @@ protected:
|
||||
CGSolver T_solver; // Implicit solver for T = M + dt K
|
||||
HypreSmoother T_prec; // Preconditioner for the implicit solver
|
||||
|
||||
double alpha, kappa;
|
||||
real_t alpha, kappa;
|
||||
|
||||
mutable Vector z; // auxiliary vector
|
||||
|
||||
public:
|
||||
ConductionOperator(ParFiniteElementSpace &f, double alpha, double kappa,
|
||||
ConductionOperator(ParFiniteElementSpace &f, real_t alpha, real_t kappa,
|
||||
const Vector &u);
|
||||
|
||||
virtual void Mult(const Vector &u, Vector &du_dt) const;
|
||||
/** Solve the Backward-Euler equation: k = f(u + dt*k, t), for the unknown k.
|
||||
This is the only requirement for high-order SDIRK implicit integration.*/
|
||||
virtual void ImplicitSolve(const double dt, const Vector &u, Vector &k);
|
||||
virtual void ImplicitSolve(const real_t dt, const Vector &u, Vector &k);
|
||||
|
||||
/// Update the diffusion BilinearForm K using the given true-dof vector `u`.
|
||||
void SetParameters(const Vector &u);
|
||||
@@ -89,7 +89,7 @@ public:
|
||||
virtual ~ConductionOperator();
|
||||
};
|
||||
|
||||
double InitialTemperature(const Vector &x);
|
||||
real_t InitialTemperature(const Vector &x);
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
@@ -105,10 +105,10 @@ int main(int argc, char *argv[])
|
||||
int par_ref_levels = 1;
|
||||
int order = 2;
|
||||
int ode_solver_type = 3;
|
||||
double t_final = 0.5;
|
||||
double dt = 1.0e-2;
|
||||
double alpha = 1.0e-2;
|
||||
double kappa = 0.5;
|
||||
real_t t_final = 0.5;
|
||||
real_t dt = 1.0e-2;
|
||||
real_t alpha = 1.0e-2;
|
||||
real_t kappa = 0.5;
|
||||
bool visualization = true;
|
||||
bool visit = false;
|
||||
int vis_steps = 5;
|
||||
@@ -313,7 +313,7 @@ int main(int argc, char *argv[])
|
||||
// 10. Perform time-integration (looping over the time iterations, ti, with a
|
||||
// time-step dt).
|
||||
ode_solver->Init(oper);
|
||||
double t = 0.0;
|
||||
real_t t = 0.0;
|
||||
|
||||
bool last_step = false;
|
||||
for (int ti = 1; !last_step; ti++)
|
||||
@@ -382,13 +382,13 @@ int main(int argc, char *argv[])
|
||||
return 0;
|
||||
}
|
||||
|
||||
ConductionOperator::ConductionOperator(ParFiniteElementSpace &f, double al,
|
||||
double kap, const Vector &u)
|
||||
: TimeDependentOperator(f.GetTrueVSize(), 0.0), fespace(f), M(NULL), K(NULL),
|
||||
T(NULL), current_dt(0.0),
|
||||
ConductionOperator::ConductionOperator(ParFiniteElementSpace &f, real_t al,
|
||||
real_t kap, const Vector &u)
|
||||
: TimeDependentOperator(f.GetTrueVSize(), (real_t) 0.0), fespace(f),
|
||||
M(NULL), K(NULL), T(NULL), current_dt(0.0),
|
||||
M_solver(f.GetComm()), T_solver(f.GetComm()), z(height)
|
||||
{
|
||||
const double rel_tol = 1e-8;
|
||||
const real_t rel_tol = 1e-8;
|
||||
|
||||
M = new ParBilinearForm(&fespace);
|
||||
M->AddDomainIntegrator(new MassIntegrator());
|
||||
@@ -427,7 +427,7 @@ void ConductionOperator::Mult(const Vector &u, Vector &du_dt) const
|
||||
M_solver.Mult(z, du_dt);
|
||||
}
|
||||
|
||||
void ConductionOperator::ImplicitSolve(const double dt,
|
||||
void ConductionOperator::ImplicitSolve(const real_t dt,
|
||||
const Vector &u, Vector &du_dt)
|
||||
{
|
||||
// Solve the equation:
|
||||
@@ -473,7 +473,7 @@ ConductionOperator::~ConductionOperator()
|
||||
delete K;
|
||||
}
|
||||
|
||||
double InitialTemperature(const Vector &x)
|
||||
real_t InitialTemperature(const Vector &x)
|
||||
{
|
||||
if (x.Norml2() < 0.5)
|
||||
{
|
||||
|
||||
+8
-8
@@ -69,7 +69,7 @@ public:
|
||||
void SetDisplacement(GridFunction &u_) { u = &u_; }
|
||||
void SetComponent(int i, int j) { si = i; sj = j; }
|
||||
|
||||
virtual double Eval(ElementTransformation &T, const IntegrationPoint &ip);
|
||||
virtual real_t Eval(ElementTransformation &T, const IntegrationPoint &ip);
|
||||
};
|
||||
|
||||
// Simple GLVis visualization manager.
|
||||
@@ -104,8 +104,8 @@ int main(int argc, char *argv[])
|
||||
const char *mesh_file = "../data/beam-tri.mesh";
|
||||
int ref_levels = -1;
|
||||
int order = 1;
|
||||
double alpha = -1.0;
|
||||
double kappa = -1.0;
|
||||
real_t alpha = -1.0;
|
||||
real_t kappa = -1.0;
|
||||
bool visualization = 1;
|
||||
|
||||
OptionsParser args(argc, argv);
|
||||
@@ -245,7 +245,7 @@ int main(int argc, char *argv[])
|
||||
// solve the system Ax=b with PCG for the symmetric formulation, or GMRES
|
||||
// for the non-symmetric.
|
||||
GSSmoother M(A);
|
||||
const double rtol = 1e-6;
|
||||
const real_t rtol = 1e-6;
|
||||
if (alpha == -1.0)
|
||||
{
|
||||
PCG(A, M, B, X, 3, 5000, rtol*rtol, 0.0);
|
||||
@@ -337,17 +337,17 @@ void InitDisplacement(const Vector &x, Vector &u)
|
||||
}
|
||||
|
||||
|
||||
double StressCoefficient::Eval(ElementTransformation &T,
|
||||
real_t StressCoefficient::Eval(ElementTransformation &T,
|
||||
const IntegrationPoint &ip)
|
||||
{
|
||||
MFEM_ASSERT(u != NULL, "displacement field is not set");
|
||||
|
||||
double L = lambda.Eval(T, ip);
|
||||
double M = mu.Eval(T, ip);
|
||||
real_t L = lambda.Eval(T, ip);
|
||||
real_t M = mu.Eval(T, ip);
|
||||
u->GetVectorGradient(T, grad);
|
||||
if (si == sj)
|
||||
{
|
||||
double div_u = grad.Trace();
|
||||
real_t div_u = grad.Trace();
|
||||
return L*div_u + 2*M*grad(si,si);
|
||||
}
|
||||
else
|
||||
|
||||
+8
-8
@@ -69,7 +69,7 @@ public:
|
||||
void SetDisplacement(GridFunction &u_) { u = &u_; }
|
||||
void SetComponent(int i, int j) { si = i; sj = j; }
|
||||
|
||||
virtual double Eval(ElementTransformation &T, const IntegrationPoint &ip);
|
||||
virtual real_t Eval(ElementTransformation &T, const IntegrationPoint &ip);
|
||||
};
|
||||
|
||||
// Simple GLVis visualization manager.
|
||||
@@ -108,8 +108,8 @@ int main(int argc, char *argv[])
|
||||
int ser_ref_levels = -1;
|
||||
int par_ref_levels = 1;
|
||||
int order = 1;
|
||||
double alpha = -1.0;
|
||||
double kappa = -1.0;
|
||||
real_t alpha = -1.0;
|
||||
real_t kappa = -1.0;
|
||||
bool amg_elast = false;
|
||||
bool visualization = 1;
|
||||
|
||||
@@ -268,7 +268,7 @@ int main(int argc, char *argv[])
|
||||
// 11. Define a simple symmetric Gauss-Seidel preconditioner and use it to
|
||||
// solve the system Ax=b with PCG for the symmetric formulation, or GMRES
|
||||
// for the non-symmetric.
|
||||
const double rtol = 1e-6;
|
||||
const real_t rtol = 1e-6;
|
||||
HypreBoomerAMG amg(A);
|
||||
if (amg_elast)
|
||||
{
|
||||
@@ -376,17 +376,17 @@ void InitDisplacement(const Vector &x, Vector &u)
|
||||
}
|
||||
|
||||
|
||||
double StressCoefficient::Eval(ElementTransformation &T,
|
||||
real_t StressCoefficient::Eval(ElementTransformation &T,
|
||||
const IntegrationPoint &ip)
|
||||
{
|
||||
MFEM_ASSERT(u != NULL, "displacement field is not set");
|
||||
|
||||
double L = lambda.Eval(T, ip);
|
||||
double M = mu.Eval(T, ip);
|
||||
real_t L = lambda.Eval(T, ip);
|
||||
real_t M = mu.Eval(T, ip);
|
||||
u->GetVectorGradient(T, grad);
|
||||
if (si == sj)
|
||||
{
|
||||
double div_u = grad.Trace();
|
||||
real_t div_u = grad.Trace();
|
||||
return L*div_u + 2*M*grad(si,si);
|
||||
}
|
||||
else
|
||||
|
||||
+10
-10
@@ -52,11 +52,11 @@ int problem;
|
||||
|
||||
// Equation constant parameters.
|
||||
const int num_equation = 4;
|
||||
const double specific_heat_ratio = 1.4;
|
||||
const double gas_constant = 1.0;
|
||||
const real_t specific_heat_ratio = 1.4;
|
||||
const real_t gas_constant = 1.0;
|
||||
|
||||
// Maximum characteristic speed (updated by integrators)
|
||||
double max_char_speed;
|
||||
real_t max_char_speed;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
@@ -66,9 +66,9 @@ int main(int argc, char *argv[])
|
||||
int ref_levels = 1;
|
||||
int order = 3;
|
||||
int ode_solver_type = 4;
|
||||
double t_final = 2.0;
|
||||
double dt = -0.01;
|
||||
double cfl = 0.3;
|
||||
real_t t_final = 2.0;
|
||||
real_t dt = -0.01;
|
||||
real_t cfl = 0.3;
|
||||
bool visualization = true;
|
||||
int vis_steps = 50;
|
||||
|
||||
@@ -228,7 +228,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
// Determine the minimum element size.
|
||||
double hmin = 0.0;
|
||||
real_t hmin = 0.0;
|
||||
if (cfl > 0)
|
||||
{
|
||||
hmin = mesh.GetElementSize(0, 1);
|
||||
@@ -242,7 +242,7 @@ int main(int argc, char *argv[])
|
||||
tic_toc.Clear();
|
||||
tic_toc.Start();
|
||||
|
||||
double t = 0.0;
|
||||
real_t t = 0.0;
|
||||
euler.SetTime(t);
|
||||
ode_solver->Init(euler);
|
||||
|
||||
@@ -260,7 +260,7 @@ int main(int argc, char *argv[])
|
||||
bool done = false;
|
||||
for (int ti = 0; !done; )
|
||||
{
|
||||
double dt_real = min(dt, t_final - t);
|
||||
real_t dt_real = min(dt, t_final - t);
|
||||
|
||||
ode_solver->Step(sol, t, dt_real);
|
||||
if (cfl > 0)
|
||||
@@ -298,7 +298,7 @@ int main(int argc, char *argv[])
|
||||
// 10. Compute the L2 solution error summed for all components.
|
||||
if (t_final == 2.0)
|
||||
{
|
||||
const double error = sol.ComputeLpError(2, u0);
|
||||
const real_t error = sol.ComputeLpError(2, u0);
|
||||
cout << "Solution error: " << error << endl;
|
||||
}
|
||||
|
||||
|
||||
+50
-50
@@ -9,11 +9,11 @@ using namespace mfem;
|
||||
extern int problem;
|
||||
|
||||
// Maximum characteristic speed (updated by integrators)
|
||||
extern double max_char_speed;
|
||||
extern real_t max_char_speed;
|
||||
|
||||
extern const int num_equation;
|
||||
extern const double specific_heat_ratio;
|
||||
extern const double gas_constant;
|
||||
extern const real_t specific_heat_ratio;
|
||||
extern const real_t gas_constant;
|
||||
|
||||
// Time-dependent operator for the right-hand side of the ODE representing the
|
||||
// DG weak form.
|
||||
@@ -52,7 +52,7 @@ private:
|
||||
|
||||
public:
|
||||
RiemannSolver();
|
||||
double Eval(const Vector &state1, const Vector &state2,
|
||||
real_t Eval(const Vector &state1, const Vector &state2,
|
||||
const Vector &nor, Vector &flux);
|
||||
};
|
||||
|
||||
@@ -149,13 +149,13 @@ void FE_Evolution::Mult(const Vector &x, Vector &y) const
|
||||
bool StateIsPhysical(const Vector &state, const int dim);
|
||||
|
||||
// Pressure (EOS) computation
|
||||
inline double ComputePressure(const Vector &state, int dim)
|
||||
inline real_t ComputePressure(const Vector &state, int dim)
|
||||
{
|
||||
const double den = state(0);
|
||||
const real_t den = state(0);
|
||||
const Vector den_vel(state.GetData() + 1, dim);
|
||||
const double den_energy = state(1 + dim);
|
||||
const real_t den_energy = state(1 + dim);
|
||||
|
||||
double den_vel2 = 0;
|
||||
real_t den_vel2 = 0;
|
||||
for (int d = 0; d < dim; d++) { den_vel2 += den_vel(d) * den_vel(d); }
|
||||
den_vel2 /= den;
|
||||
|
||||
@@ -165,13 +165,13 @@ inline double ComputePressure(const Vector &state, int dim)
|
||||
// Compute the vector flux F(u)
|
||||
void ComputeFlux(const Vector &state, int dim, DenseMatrix &flux)
|
||||
{
|
||||
const double den = state(0);
|
||||
const real_t den = state(0);
|
||||
const Vector den_vel(state.GetData() + 1, dim);
|
||||
const double den_energy = state(1 + dim);
|
||||
const real_t den_energy = state(1 + dim);
|
||||
|
||||
MFEM_ASSERT(StateIsPhysical(state, dim), "");
|
||||
|
||||
const double pres = ComputePressure(state, dim);
|
||||
const real_t pres = ComputePressure(state, dim);
|
||||
|
||||
for (int d = 0; d < dim; d++)
|
||||
{
|
||||
@@ -183,7 +183,7 @@ void ComputeFlux(const Vector &state, int dim, DenseMatrix &flux)
|
||||
flux(1+d, d) += pres;
|
||||
}
|
||||
|
||||
const double H = (den_energy + pres) / den;
|
||||
const real_t H = (den_energy + pres) / den;
|
||||
for (int d = 0; d < dim; d++)
|
||||
{
|
||||
flux(1+dim, d) = den_vel(d) * H;
|
||||
@@ -196,15 +196,15 @@ void ComputeFluxDotN(const Vector &state, const Vector &nor,
|
||||
{
|
||||
// NOTE: nor in general is not a unit normal
|
||||
const int dim = nor.Size();
|
||||
const double den = state(0);
|
||||
const real_t den = state(0);
|
||||
const Vector den_vel(state.GetData() + 1, dim);
|
||||
const double den_energy = state(1 + dim);
|
||||
const real_t den_energy = state(1 + dim);
|
||||
|
||||
MFEM_ASSERT(StateIsPhysical(state, dim), "");
|
||||
|
||||
const double pres = ComputePressure(state, dim);
|
||||
const real_t pres = ComputePressure(state, dim);
|
||||
|
||||
double den_velN = 0;
|
||||
real_t den_velN = 0;
|
||||
for (int d = 0; d < dim; d++) { den_velN += den_vel(d) * nor(d); }
|
||||
|
||||
fluxN(0) = den_velN;
|
||||
@@ -213,23 +213,23 @@ void ComputeFluxDotN(const Vector &state, const Vector &nor,
|
||||
fluxN(1+d) = den_velN * den_vel(d) / den + pres * nor(d);
|
||||
}
|
||||
|
||||
const double H = (den_energy + pres) / den;
|
||||
const real_t H = (den_energy + pres) / den;
|
||||
fluxN(1 + dim) = den_velN * H;
|
||||
}
|
||||
|
||||
// Compute the maximum characteristic speed.
|
||||
inline double ComputeMaxCharSpeed(const Vector &state, const int dim)
|
||||
inline real_t ComputeMaxCharSpeed(const Vector &state, const int dim)
|
||||
{
|
||||
const double den = state(0);
|
||||
const real_t den = state(0);
|
||||
const Vector den_vel(state.GetData() + 1, dim);
|
||||
|
||||
double den_vel2 = 0;
|
||||
real_t den_vel2 = 0;
|
||||
for (int d = 0; d < dim; d++) { den_vel2 += den_vel(d) * den_vel(d); }
|
||||
den_vel2 /= den;
|
||||
|
||||
const double pres = ComputePressure(state, dim);
|
||||
const double sound = sqrt(specific_heat_ratio * pres / den);
|
||||
const double vel = sqrt(den_vel2 / den);
|
||||
const real_t pres = ComputePressure(state, dim);
|
||||
const real_t sound = sqrt(specific_heat_ratio * pres / den);
|
||||
const real_t vel = sqrt(den_vel2 / den);
|
||||
|
||||
return vel + sound;
|
||||
}
|
||||
@@ -254,7 +254,7 @@ void FE_Evolution::GetFlux(const DenseMatrix &x_, DenseTensor &flux_) const
|
||||
}
|
||||
|
||||
// Update max char speed
|
||||
const double mcs = ComputeMaxCharSpeed(state, flux_dim);
|
||||
const real_t mcs = ComputeMaxCharSpeed(state, flux_dim);
|
||||
if (mcs > max_char_speed) { max_char_speed = mcs; }
|
||||
}
|
||||
}
|
||||
@@ -264,7 +264,7 @@ RiemannSolver::RiemannSolver() :
|
||||
flux1(num_equation),
|
||||
flux2(num_equation) { }
|
||||
|
||||
double RiemannSolver::Eval(const Vector &state1, const Vector &state2,
|
||||
real_t RiemannSolver::Eval(const Vector &state1, const Vector &state2,
|
||||
const Vector &nor, Vector &flux)
|
||||
{
|
||||
// NOTE: nor in general is not a unit normal
|
||||
@@ -273,15 +273,15 @@ double RiemannSolver::Eval(const Vector &state1, const Vector &state2,
|
||||
MFEM_ASSERT(StateIsPhysical(state1, dim), "");
|
||||
MFEM_ASSERT(StateIsPhysical(state2, dim), "");
|
||||
|
||||
const double maxE1 = ComputeMaxCharSpeed(state1, dim);
|
||||
const double maxE2 = ComputeMaxCharSpeed(state2, dim);
|
||||
const real_t maxE1 = ComputeMaxCharSpeed(state1, dim);
|
||||
const real_t maxE2 = ComputeMaxCharSpeed(state2, dim);
|
||||
|
||||
const double maxE = max(maxE1, maxE2);
|
||||
const real_t maxE = max(maxE1, maxE2);
|
||||
|
||||
ComputeFluxDotN(state1, nor, flux1);
|
||||
ComputeFluxDotN(state2, nor, flux2);
|
||||
|
||||
double normag = 0;
|
||||
real_t normag = 0;
|
||||
for (int i = 0; i < dim; i++)
|
||||
{
|
||||
normag += nor(i) * nor(i);
|
||||
@@ -359,7 +359,7 @@ void FaceIntegrator::AssembleFaceVector(const FiniteElement &el1,
|
||||
|
||||
// Get the normal vector and the flux on the face
|
||||
CalcOrtho(Tr.Jacobian(), nor);
|
||||
const double mcs = rsolver.Eval(funval1, funval2, nor, fluxN);
|
||||
const real_t mcs = rsolver.Eval(funval1, funval2, nor, fluxN);
|
||||
|
||||
// Update max char speed
|
||||
if (mcs > max_char_speed) { max_char_speed = mcs; }
|
||||
@@ -382,9 +382,9 @@ void FaceIntegrator::AssembleFaceVector(const FiniteElement &el1,
|
||||
// Check that the state is physical - enabled in debug mode
|
||||
bool StateIsPhysical(const Vector &state, const int dim)
|
||||
{
|
||||
const double den = state(0);
|
||||
const real_t den = state(0);
|
||||
const Vector den_vel(state.GetData() + 1, dim);
|
||||
const double den_energy = state(1 + dim);
|
||||
const real_t den_energy = state(1 + dim);
|
||||
|
||||
if (den < 0)
|
||||
{
|
||||
@@ -407,11 +407,11 @@ bool StateIsPhysical(const Vector &state, const int dim)
|
||||
return false;
|
||||
}
|
||||
|
||||
double den_vel2 = 0;
|
||||
real_t den_vel2 = 0;
|
||||
for (int i = 0; i < dim; i++) { den_vel2 += den_vel(i) * den_vel(i); }
|
||||
den_vel2 /= den;
|
||||
|
||||
const double pres = (specific_heat_ratio - 1.0) * (den_energy - 0.5 * den_vel2);
|
||||
const real_t pres = (specific_heat_ratio - 1.0) * (den_energy - 0.5 * den_vel2);
|
||||
|
||||
if (pres <= 0)
|
||||
{
|
||||
@@ -431,7 +431,7 @@ void InitialCondition(const Vector &x, Vector &y)
|
||||
{
|
||||
MFEM_ASSERT(x.Size() == 2, "");
|
||||
|
||||
double radius = 0, Minf = 0, beta = 0;
|
||||
real_t radius = 0, Minf = 0, beta = 0;
|
||||
if (problem == 1)
|
||||
{
|
||||
// "Fast vortex"
|
||||
@@ -452,36 +452,36 @@ void InitialCondition(const Vector &x, Vector &y)
|
||||
"Options are: 1 - fast vortex, 2 - slow vortex");
|
||||
}
|
||||
|
||||
const double xc = 0.0, yc = 0.0;
|
||||
const real_t xc = 0.0, yc = 0.0;
|
||||
|
||||
// Nice units
|
||||
const double vel_inf = 1.;
|
||||
const double den_inf = 1.;
|
||||
const real_t vel_inf = 1.;
|
||||
const real_t den_inf = 1.;
|
||||
|
||||
// Derive remainder of background state from this and Minf
|
||||
const double pres_inf = (den_inf / specific_heat_ratio) * (vel_inf / Minf) *
|
||||
const real_t pres_inf = (den_inf / specific_heat_ratio) * (vel_inf / Minf) *
|
||||
(vel_inf / Minf);
|
||||
const double temp_inf = pres_inf / (den_inf * gas_constant);
|
||||
const real_t temp_inf = pres_inf / (den_inf * gas_constant);
|
||||
|
||||
double r2rad = 0.0;
|
||||
real_t r2rad = 0.0;
|
||||
r2rad += (x(0) - xc) * (x(0) - xc);
|
||||
r2rad += (x(1) - yc) * (x(1) - yc);
|
||||
r2rad /= (radius * radius);
|
||||
|
||||
const double shrinv1 = 1.0 / (specific_heat_ratio - 1.);
|
||||
const real_t shrinv1 = 1.0 / (specific_heat_ratio - 1.);
|
||||
|
||||
const double velX = vel_inf * (1 - beta * (x(1) - yc) / radius * exp(
|
||||
const real_t velX = vel_inf * (1 - beta * (x(1) - yc) / radius * exp(
|
||||
-0.5 * r2rad));
|
||||
const double velY = vel_inf * beta * (x(0) - xc) / radius * exp(-0.5 * r2rad);
|
||||
const double vel2 = velX * velX + velY * velY;
|
||||
const real_t velY = vel_inf * beta * (x(0) - xc) / radius * exp(-0.5 * r2rad);
|
||||
const real_t vel2 = velX * velX + velY * velY;
|
||||
|
||||
const double specific_heat = gas_constant * specific_heat_ratio * shrinv1;
|
||||
const double temp = temp_inf - 0.5 * (vel_inf * beta) *
|
||||
const real_t specific_heat = gas_constant * specific_heat_ratio * shrinv1;
|
||||
const real_t temp = temp_inf - 0.5 * (vel_inf * beta) *
|
||||
(vel_inf * beta) / specific_heat * exp(-r2rad);
|
||||
|
||||
const double den = den_inf * pow(temp/temp_inf, shrinv1);
|
||||
const double pres = den * gas_constant * temp;
|
||||
const double energy = shrinv1 * pres / den + 0.5 * vel2;
|
||||
const real_t den = den_inf * pow(temp/temp_inf, shrinv1);
|
||||
const real_t pres = den * gas_constant * temp;
|
||||
const real_t energy = shrinv1 * pres / den + 0.5 * vel2;
|
||||
|
||||
y(0) = den;
|
||||
y(1) = den * velX;
|
||||
|
||||
+19
-18
@@ -52,11 +52,11 @@ int problem;
|
||||
|
||||
// Equation constant parameters.
|
||||
const int num_equation = 4;
|
||||
const double specific_heat_ratio = 1.4;
|
||||
const double gas_constant = 1.0;
|
||||
const real_t specific_heat_ratio = 1.4;
|
||||
const real_t gas_constant = 1.0;
|
||||
|
||||
// Maximum characteristic speed (updated by integrators)
|
||||
double max_char_speed;
|
||||
real_t max_char_speed;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
@@ -71,9 +71,9 @@ int main(int argc, char *argv[])
|
||||
int par_ref_levels = 1;
|
||||
int order = 3;
|
||||
int ode_solver_type = 4;
|
||||
double t_final = 2.0;
|
||||
double dt = -0.01;
|
||||
double cfl = 0.3;
|
||||
real_t t_final = 2.0;
|
||||
real_t dt = -0.01;
|
||||
real_t cfl = 0.3;
|
||||
bool visualization = true;
|
||||
int vis_steps = 50;
|
||||
|
||||
@@ -270,23 +270,24 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
// Determine the minimum element size.
|
||||
double hmin;
|
||||
real_t hmin;
|
||||
if (cfl > 0)
|
||||
{
|
||||
double my_hmin = pmesh.GetElementSize(0, 1);
|
||||
real_t my_hmin = pmesh.GetElementSize(0, 1);
|
||||
for (int i = 1; i < pmesh.GetNE(); i++)
|
||||
{
|
||||
my_hmin = min(pmesh.GetElementSize(i, 1), my_hmin);
|
||||
}
|
||||
// Reduce to find the global minimum element size
|
||||
MPI_Allreduce(&my_hmin, &hmin, 1, MPI_DOUBLE, MPI_MIN, pmesh.GetComm());
|
||||
MPI_Allreduce(&my_hmin, &hmin, 1, MPITypeMap<real_t>::mpi_type,
|
||||
MPI_MIN, pmesh.GetComm());
|
||||
}
|
||||
|
||||
// Start the timer.
|
||||
tic_toc.Clear();
|
||||
tic_toc.Start();
|
||||
|
||||
double t = 0.0;
|
||||
real_t t = 0.0;
|
||||
euler.SetTime(t);
|
||||
ode_solver->Init(euler);
|
||||
|
||||
@@ -299,9 +300,9 @@ int main(int argc, char *argv[])
|
||||
A.Mult(sol, z);
|
||||
// Reduce to find the global maximum wave speed
|
||||
{
|
||||
double all_max_char_speed;
|
||||
MPI_Allreduce(&max_char_speed, &all_max_char_speed,
|
||||
1, MPI_DOUBLE, MPI_MAX, pmesh.GetComm());
|
||||
real_t all_max_char_speed;
|
||||
MPI_Allreduce(&max_char_speed, &all_max_char_speed, 1,
|
||||
MPITypeMap<real_t>::mpi_type, MPI_MAX, pmesh.GetComm());
|
||||
max_char_speed = all_max_char_speed;
|
||||
}
|
||||
dt = cfl * hmin / max_char_speed / (2*order+1);
|
||||
@@ -311,16 +312,16 @@ int main(int argc, char *argv[])
|
||||
bool done = false;
|
||||
for (int ti = 0; !done; )
|
||||
{
|
||||
double dt_real = min(dt, t_final - t);
|
||||
real_t dt_real = min(dt, t_final - t);
|
||||
|
||||
ode_solver->Step(sol, t, dt_real);
|
||||
if (cfl > 0)
|
||||
{
|
||||
// Reduce to find the global maximum wave speed
|
||||
{
|
||||
double all_max_char_speed;
|
||||
MPI_Allreduce(&max_char_speed, &all_max_char_speed,
|
||||
1, MPI_DOUBLE, MPI_MAX, pmesh.GetComm());
|
||||
real_t all_max_char_speed;
|
||||
MPI_Allreduce(&max_char_speed, &all_max_char_speed, 1,
|
||||
MPITypeMap<real_t>::mpi_type, MPI_MAX, pmesh.GetComm());
|
||||
max_char_speed = all_max_char_speed;
|
||||
}
|
||||
dt = cfl * hmin / max_char_speed / (2*order+1);
|
||||
@@ -366,7 +367,7 @@ int main(int argc, char *argv[])
|
||||
// 12. Compute the L2 solution error summed for all components.
|
||||
if (t_final == 2.0)
|
||||
{
|
||||
const double error = sol.ComputeLpError(2, u0);
|
||||
const real_t error = sol.ComputeLpError(2, u0);
|
||||
if (Mpi::Root())
|
||||
{
|
||||
cout << "Solution error: " << error << endl;
|
||||
|
||||
+10
-10
@@ -48,15 +48,15 @@ public:
|
||||
print_level = print_lvl;
|
||||
}
|
||||
|
||||
virtual void MonitorResidual(int it, double norm, const Vector &r, bool final);
|
||||
virtual void MonitorResidual(int it, real_t norm, const Vector &r, bool final);
|
||||
|
||||
private:
|
||||
const std::string prefix;
|
||||
int print_level;
|
||||
mutable double norm0;
|
||||
mutable real_t norm0;
|
||||
};
|
||||
|
||||
void GeneralResidualMonitor::MonitorResidual(int it, double norm,
|
||||
void GeneralResidualMonitor::MonitorResidual(int it, real_t norm,
|
||||
const Vector &r, bool final)
|
||||
{
|
||||
if (print_level == 1 || (print_level == 3 && (final || it == 0)))
|
||||
@@ -103,7 +103,7 @@ protected:
|
||||
BlockOperator *jacobian;
|
||||
|
||||
// Scaling factor for the pressure mass matrix in the block preconditioner
|
||||
double gamma;
|
||||
real_t gamma;
|
||||
|
||||
// Objects for the block preconditioner application
|
||||
SparseMatrix *pressure_mass;
|
||||
@@ -157,7 +157,7 @@ protected:
|
||||
|
||||
public:
|
||||
RubberOperator(Array<FiniteElementSpace *> &fes, Array<Array<int> *>&ess_bdr,
|
||||
Array<int> &block_trueOffsets, double rel_tol, double abs_tol,
|
||||
Array<int> &block_trueOffsets, real_t rel_tol, real_t abs_tol,
|
||||
int iter, Coefficient &mu);
|
||||
|
||||
// Required to use the native newton solver
|
||||
@@ -187,10 +187,10 @@ int main(int argc, char *argv[])
|
||||
int ref_levels = 0;
|
||||
int order = 2;
|
||||
bool visualization = true;
|
||||
double newton_rel_tol = 1e-4;
|
||||
double newton_abs_tol = 1e-6;
|
||||
real_t newton_rel_tol = 1e-4;
|
||||
real_t newton_abs_tol = 1e-6;
|
||||
int newton_iter = 500;
|
||||
double mu = 1.0;
|
||||
real_t mu = 1.0;
|
||||
|
||||
OptionsParser args(argc, argv);
|
||||
args.AddOption(&mesh_file, "-m", "--mesh",
|
||||
@@ -449,8 +449,8 @@ JacobianPreconditioner::~JacobianPreconditioner()
|
||||
RubberOperator::RubberOperator(Array<FiniteElementSpace *> &fes,
|
||||
Array<Array<int> *> &ess_bdr,
|
||||
Array<int> &offsets,
|
||||
double rel_tol,
|
||||
double abs_tol,
|
||||
real_t rel_tol,
|
||||
real_t abs_tol,
|
||||
int iter,
|
||||
Coefficient &c_mu)
|
||||
: Operator(fes[0]->GetTrueVSize() + fes[1]->GetTrueVSize()),
|
||||
|
||||
+10
-10
@@ -62,15 +62,15 @@ public:
|
||||
#endif
|
||||
}
|
||||
|
||||
virtual void MonitorResidual(int it, double norm, const Vector &r, bool final);
|
||||
virtual void MonitorResidual(int it, real_t norm, const Vector &r, bool final);
|
||||
|
||||
private:
|
||||
const std::string prefix;
|
||||
int print_level;
|
||||
mutable double norm0;
|
||||
mutable real_t norm0;
|
||||
};
|
||||
|
||||
void GeneralResidualMonitor::MonitorResidual(int it, double norm,
|
||||
void GeneralResidualMonitor::MonitorResidual(int it, real_t norm,
|
||||
const Vector &r, bool final)
|
||||
{
|
||||
if (print_level == 1 || (print_level == 3 && (final || it == 0)))
|
||||
@@ -117,7 +117,7 @@ protected:
|
||||
BlockOperator *jacobian;
|
||||
|
||||
// Scaling factor for the pressure mass matrix in the block preconditioner
|
||||
double gamma;
|
||||
real_t gamma;
|
||||
|
||||
// Objects for the block preconditioner application
|
||||
Operator *pressure_mass;
|
||||
@@ -171,7 +171,7 @@ protected:
|
||||
|
||||
public:
|
||||
RubberOperator(Array<ParFiniteElementSpace *> &fes, Array<Array<int> *>&ess_bdr,
|
||||
Array<int> &block_trueOffsets, double rel_tol, double abs_tol,
|
||||
Array<int> &block_trueOffsets, real_t rel_tol, real_t abs_tol,
|
||||
int iter, Coefficient &mu);
|
||||
|
||||
// Required to use the native newton solver
|
||||
@@ -214,10 +214,10 @@ int main(int argc, char *argv[])
|
||||
int par_ref_levels = 0;
|
||||
int order = 2;
|
||||
bool visualization = true;
|
||||
double newton_rel_tol = 1e-4;
|
||||
double newton_abs_tol = 1e-6;
|
||||
real_t newton_rel_tol = 1e-4;
|
||||
real_t newton_abs_tol = 1e-6;
|
||||
int newton_iter = 500;
|
||||
double mu = 1.0;
|
||||
real_t mu = 1.0;
|
||||
|
||||
OptionsParser args(argc, argv);
|
||||
args.AddOption(&mesh_file, "-m", "--mesh",
|
||||
@@ -524,8 +524,8 @@ JacobianPreconditioner::~JacobianPreconditioner()
|
||||
RubberOperator::RubberOperator(Array<ParFiniteElementSpace *> &fes,
|
||||
Array<Array<int> *> &ess_bdr,
|
||||
Array<int> &trueOffsets,
|
||||
double rel_tol,
|
||||
double abs_tol,
|
||||
real_t rel_tol,
|
||||
real_t abs_tol,
|
||||
int iter,
|
||||
Coefficient &c_mu)
|
||||
: Operator(fes[0]->TrueVSize() + fes[1]->TrueVSize()),
|
||||
|
||||
+10
-10
@@ -69,11 +69,11 @@ using namespace mfem;
|
||||
|
||||
// Constants used in the Hamiltonian
|
||||
static int prob_ = 0;
|
||||
static double m_ = 1.0;
|
||||
static double k_ = 1.0;
|
||||
static real_t m_ = 1.0;
|
||||
static real_t k_ = 1.0;
|
||||
|
||||
// Hamiltonian functional, see below for implementation
|
||||
double hamiltonian(double q, double p, double t);
|
||||
real_t hamiltonian(real_t q, real_t p, real_t t);
|
||||
|
||||
class GradT : public Operator
|
||||
{
|
||||
@@ -94,7 +94,7 @@ int main(int argc, char *argv[])
|
||||
// 1. Parse command-line options.
|
||||
int order = 1;
|
||||
int nsteps = 100;
|
||||
double dt = 0.1;
|
||||
real_t dt = 0.1;
|
||||
bool visualization = true;
|
||||
bool gnuplot = false;
|
||||
|
||||
@@ -136,7 +136,7 @@ int main(int argc, char *argv[])
|
||||
siaSolver.Init(P,F);
|
||||
|
||||
// 3. Set the initial conditions
|
||||
double t = 0.0;
|
||||
real_t t = 0.0;
|
||||
Vector q(1), p(1);
|
||||
Vector e(nsteps+1);
|
||||
q(0) = 0.0;
|
||||
@@ -160,7 +160,7 @@ int main(int argc, char *argv[])
|
||||
Vector x1(3); x1 = 0.0;
|
||||
|
||||
// 6. Perform time-stepping
|
||||
double e_mean = 0.0;
|
||||
real_t e_mean = 0.0;
|
||||
|
||||
for (int i = 0; i < nsteps; i++)
|
||||
{
|
||||
@@ -210,13 +210,13 @@ int main(int argc, char *argv[])
|
||||
|
||||
// 7. Compute and display mean and standard deviation of the energy
|
||||
e_mean /= (nsteps + 1);
|
||||
double e_var = 0.0;
|
||||
real_t e_var = 0.0;
|
||||
for (int i=0; i<=nsteps; i++)
|
||||
{
|
||||
e_var += pow(e[i] - e_mean, 2);
|
||||
}
|
||||
e_var /= (nsteps + 1);
|
||||
double e_sd = sqrt(e_var);
|
||||
real_t e_sd = sqrt(e_var);
|
||||
cout << endl << "Mean and standard deviation of the energy" << endl;
|
||||
cout << e_mean << "\t" << e_sd << endl;
|
||||
|
||||
@@ -256,9 +256,9 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
double hamiltonian(double q, double p, double t)
|
||||
real_t hamiltonian(real_t q, real_t p, real_t t)
|
||||
{
|
||||
double h = 1.0 - 0.5 / m_ + 0.5 * p * p / m_;
|
||||
real_t h = 1.0 - 0.5 / m_ + 0.5 * p * p / m_;
|
||||
switch (prob_)
|
||||
{
|
||||
case 1:
|
||||
|
||||
+16
-15
@@ -74,11 +74,11 @@ using namespace mfem;
|
||||
|
||||
// Constants used in the Hamiltonian
|
||||
static int prob_ = 0;
|
||||
static double m_ = 1.0;
|
||||
static double k_ = 1.0;
|
||||
static real_t m_ = 1.0;
|
||||
static real_t k_ = 1.0;
|
||||
|
||||
// Hamiltonian functional, see below for implementation
|
||||
double hamiltonian(double q, double p, double t);
|
||||
real_t hamiltonian(real_t q, real_t p, real_t t);
|
||||
|
||||
class GradT : public Operator
|
||||
{
|
||||
@@ -106,7 +106,7 @@ int main(int argc, char *argv[])
|
||||
// 2. Parse command-line options.
|
||||
int order = 1;
|
||||
int nsteps = 100;
|
||||
double dt = 0.1;
|
||||
real_t dt = 0.1;
|
||||
bool visualization = true;
|
||||
bool gnuplot = false;
|
||||
|
||||
@@ -154,11 +154,11 @@ int main(int argc, char *argv[])
|
||||
siaSolver.Init(P,F);
|
||||
|
||||
// 4. Set the initial conditions
|
||||
double t = 0.0;
|
||||
real_t t = 0.0;
|
||||
Vector q(1), p(1);
|
||||
Vector e(nsteps+1);
|
||||
q(0) = sin(2.0*M_PI*(double)myid/num_procs);
|
||||
p(0) = cos(2.0*M_PI*(double)myid/num_procs);
|
||||
q(0) = sin(2.0*M_PI*(real_t)myid/num_procs);
|
||||
p(0) = cos(2.0*M_PI*(real_t)myid/num_procs);
|
||||
|
||||
// 5. Prepare GnuPlot output file if needed
|
||||
ostringstream oss;
|
||||
@@ -181,7 +181,7 @@ int main(int argc, char *argv[])
|
||||
Vector x1(3); x1 = 0.0;
|
||||
|
||||
// 7. Perform time-stepping
|
||||
double e_mean = 0.0;
|
||||
real_t e_mean = 0.0;
|
||||
|
||||
for (int i = 0; i < nsteps; i++)
|
||||
{
|
||||
@@ -238,20 +238,21 @@ int main(int argc, char *argv[])
|
||||
|
||||
// 8. Compute and display mean and standard deviation of the energy
|
||||
e_mean /= (nsteps + 1);
|
||||
double e_var = 0.0;
|
||||
real_t e_var = 0.0;
|
||||
for (int i = 0; i <= nsteps; i++)
|
||||
{
|
||||
e_var += pow(e[i] - e_mean, 2);
|
||||
}
|
||||
e_var /= (nsteps + 1);
|
||||
double e_sd = sqrt(e_var);
|
||||
real_t e_sd = sqrt(e_var);
|
||||
|
||||
double e_loc_stats[2];
|
||||
double *e_stats = (myid == 0) ? new double[2 * num_procs] : (double*)NULL;
|
||||
real_t e_loc_stats[2];
|
||||
real_t *e_stats = (myid == 0) ? new real_t[2 * num_procs] : (real_t*)NULL;
|
||||
|
||||
e_loc_stats[0] = e_mean;
|
||||
e_loc_stats[1] = e_sd;
|
||||
MPI_Gather(e_loc_stats, 2, MPI_DOUBLE, e_stats, 2, MPI_DOUBLE, 0, comm);
|
||||
MPI_Gather(e_loc_stats, 2, MPITypeMap<real_t>::mpi_type, e_stats, 2,
|
||||
MPITypeMap<real_t>::mpi_type, 0, comm);
|
||||
|
||||
if (myid == 0)
|
||||
{
|
||||
@@ -324,9 +325,9 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
double hamiltonian(double q, double p, double t)
|
||||
real_t hamiltonian(real_t q, real_t p, real_t t)
|
||||
{
|
||||
double h = 1.0 - 0.5 / m_ + 0.5 * p * p / m_;
|
||||
real_t h = 1.0 - 0.5 / m_ + 0.5 * p * p / m_;
|
||||
switch (prob_)
|
||||
{
|
||||
case 1:
|
||||
|
||||
+18
-18
@@ -57,13 +57,13 @@
|
||||
using namespace std;
|
||||
using namespace mfem;
|
||||
|
||||
static double mu_ = 1.0;
|
||||
static double epsilon_ = 1.0;
|
||||
static double sigma_ = 20.0;
|
||||
static double omega_ = 10.0;
|
||||
static real_t mu_ = 1.0;
|
||||
static real_t epsilon_ = 1.0;
|
||||
static real_t sigma_ = 20.0;
|
||||
static real_t omega_ = 10.0;
|
||||
|
||||
double u0_real_exact(const Vector &);
|
||||
double u0_imag_exact(const Vector &);
|
||||
real_t u0_real_exact(const Vector &);
|
||||
real_t u0_imag_exact(const Vector &);
|
||||
|
||||
void u1_real_exact(const Vector &, Vector &);
|
||||
void u1_imag_exact(const Vector &, Vector &);
|
||||
@@ -80,8 +80,8 @@ int main(int argc, char *argv[])
|
||||
int ref_levels = 0;
|
||||
int order = 1;
|
||||
int prob = 0;
|
||||
double freq = -1.0;
|
||||
double a_coef = 0.0;
|
||||
real_t freq = -1.0;
|
||||
real_t a_coef = 0.0;
|
||||
bool visualization = 1;
|
||||
bool herm_conv = true;
|
||||
bool exact_sol = true;
|
||||
@@ -412,7 +412,7 @@ int main(int argc, char *argv[])
|
||||
break; // This should be unreachable
|
||||
}
|
||||
}
|
||||
double s = (prob != 1) ? 1.0 : -1.0;
|
||||
real_t s = (prob != 1) ? 1.0 : -1.0;
|
||||
pc_i = new ScaledOperator(pc_r,
|
||||
(conv == ComplexOperator::HERMITIAN) ?
|
||||
s:-s);
|
||||
@@ -436,8 +436,8 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (exact_sol)
|
||||
{
|
||||
double err_r = -1.0;
|
||||
double err_i = -1.0;
|
||||
real_t err_r = -1.0;
|
||||
real_t err_i = -1.0;
|
||||
|
||||
switch (prob)
|
||||
{
|
||||
@@ -524,7 +524,7 @@ int main(int argc, char *argv[])
|
||||
int i = 0;
|
||||
while (sol_sock)
|
||||
{
|
||||
double t = (double)(i % num_frames) / num_frames;
|
||||
real_t t = (real_t)(i % num_frames) / num_frames;
|
||||
ostringstream oss;
|
||||
oss << "Harmonic Solution (t = " << t << " T)";
|
||||
|
||||
@@ -555,21 +555,21 @@ bool check_for_inline_mesh(const char * mesh_file)
|
||||
return s0 == "inline-";
|
||||
}
|
||||
|
||||
complex<double> u0_exact(const Vector &x)
|
||||
complex<real_t> u0_exact(const Vector &x)
|
||||
{
|
||||
int dim = x.Size();
|
||||
complex<double> i(0.0, 1.0);
|
||||
complex<double> alpha = (epsilon_ * omega_ - i * sigma_);
|
||||
complex<double> kappa = std::sqrt(mu_ * omega_* alpha);
|
||||
complex<real_t> i(0.0, 1.0);
|
||||
complex<real_t> alpha = (epsilon_ * omega_ - i * sigma_);
|
||||
complex<real_t> kappa = std::sqrt(mu_ * omega_* alpha);
|
||||
return std::exp(-i * kappa * x[dim - 1]);
|
||||
}
|
||||
|
||||
double u0_real_exact(const Vector &x)
|
||||
real_t u0_real_exact(const Vector &x)
|
||||
{
|
||||
return u0_exact(x).real();
|
||||
}
|
||||
|
||||
double u0_imag_exact(const Vector &x)
|
||||
real_t u0_imag_exact(const Vector &x)
|
||||
{
|
||||
return u0_exact(x).imag();
|
||||
}
|
||||
|
||||
+17
-17
@@ -57,13 +57,13 @@
|
||||
using namespace std;
|
||||
using namespace mfem;
|
||||
|
||||
static double mu_ = 1.0;
|
||||
static double epsilon_ = 1.0;
|
||||
static double sigma_ = 20.0;
|
||||
static double omega_ = 10.0;
|
||||
static real_t mu_ = 1.0;
|
||||
static real_t epsilon_ = 1.0;
|
||||
static real_t sigma_ = 20.0;
|
||||
static real_t omega_ = 10.0;
|
||||
|
||||
double u0_real_exact(const Vector &);
|
||||
double u0_imag_exact(const Vector &);
|
||||
real_t u0_real_exact(const Vector &);
|
||||
real_t u0_imag_exact(const Vector &);
|
||||
|
||||
void u1_real_exact(const Vector &, Vector &);
|
||||
void u1_imag_exact(const Vector &, Vector &);
|
||||
@@ -87,8 +87,8 @@ int main(int argc, char *argv[])
|
||||
int par_ref_levels = 1;
|
||||
int order = 1;
|
||||
int prob = 0;
|
||||
double freq = -1.0;
|
||||
double a_coef = 0.0;
|
||||
real_t freq = -1.0;
|
||||
real_t a_coef = 0.0;
|
||||
bool visualization = 1;
|
||||
bool herm_conv = true;
|
||||
bool exact_sol = true;
|
||||
@@ -475,8 +475,8 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (exact_sol)
|
||||
{
|
||||
double err_r = -1.0;
|
||||
double err_i = -1.0;
|
||||
real_t err_r = -1.0;
|
||||
real_t err_i = -1.0;
|
||||
|
||||
switch (prob)
|
||||
{
|
||||
@@ -576,7 +576,7 @@ int main(int argc, char *argv[])
|
||||
int i = 0;
|
||||
while (sol_sock)
|
||||
{
|
||||
double t = (double)(i % num_frames) / num_frames;
|
||||
real_t t = (real_t)(i % num_frames) / num_frames;
|
||||
ostringstream oss;
|
||||
oss << "Harmonic Solution (t = " << t << " T)";
|
||||
|
||||
@@ -608,21 +608,21 @@ bool check_for_inline_mesh(const char * mesh_file)
|
||||
return s0 == "inline-";
|
||||
}
|
||||
|
||||
complex<double> u0_exact(const Vector &x)
|
||||
complex<real_t> u0_exact(const Vector &x)
|
||||
{
|
||||
int dim = x.Size();
|
||||
complex<double> i(0.0, 1.0);
|
||||
complex<double> alpha = (epsilon_ * omega_ - i * sigma_);
|
||||
complex<double> kappa = std::sqrt(mu_ * omega_* alpha);
|
||||
complex<real_t> i(0.0, 1.0);
|
||||
complex<real_t> alpha = (epsilon_ * omega_ - i * sigma_);
|
||||
complex<real_t> kappa = std::sqrt(mu_ * omega_* alpha);
|
||||
return std::exp(-i * kappa * x[dim - 1]);
|
||||
}
|
||||
|
||||
double u0_real_exact(const Vector &x)
|
||||
real_t u0_real_exact(const Vector &x)
|
||||
{
|
||||
return u0_exact(x).real();
|
||||
}
|
||||
|
||||
double u0_imag_exact(const Vector &x)
|
||||
real_t u0_imag_exact(const Vector &x)
|
||||
{
|
||||
return u0_exact(x).imag();
|
||||
}
|
||||
|
||||
+14
-15
@@ -46,7 +46,7 @@ protected:
|
||||
|
||||
SparseMatrix Mmat, Kmat, Kmat0;
|
||||
SparseMatrix *T; // T = M + dt K
|
||||
double current_dt;
|
||||
real_t current_dt;
|
||||
|
||||
CGSolver M_solver; // Krylov solver for inverting the mass matrix M
|
||||
DSmoother M_prec; // Preconditioner for the mass matrix M
|
||||
@@ -58,7 +58,7 @@ protected:
|
||||
mutable Vector z; // auxiliary vector
|
||||
|
||||
public:
|
||||
WaveOperator(FiniteElementSpace &f, Array<int> &ess_bdr,double speed);
|
||||
WaveOperator(FiniteElementSpace &f, Array<int> &ess_bdr, real_t speed);
|
||||
|
||||
using SecondOrderTimeDependentOperator::Mult;
|
||||
virtual void Mult(const Vector &u, const Vector &du_dt,
|
||||
@@ -68,7 +68,7 @@ public:
|
||||
d2udt2 = f(u + fac0*d2udt2,dudt + fac1*d2udt2, t),
|
||||
for the unknown d2udt2. */
|
||||
using SecondOrderTimeDependentOperator::ImplicitSolve;
|
||||
virtual void ImplicitSolve(const double fac0, const double fac1,
|
||||
virtual void ImplicitSolve(const real_t fac0, const real_t fac1,
|
||||
const Vector &u, const Vector &dudt, Vector &d2udt2);
|
||||
|
||||
///
|
||||
@@ -79,12 +79,11 @@ public:
|
||||
|
||||
|
||||
WaveOperator::WaveOperator(FiniteElementSpace &f,
|
||||
Array<int> &ess_bdr, double speed)
|
||||
: SecondOrderTimeDependentOperator(f.GetTrueVSize(), 0.0), fespace(f), M(NULL),
|
||||
K(NULL),
|
||||
T(NULL), current_dt(0.0), z(height)
|
||||
Array<int> &ess_bdr, real_t speed)
|
||||
: SecondOrderTimeDependentOperator(f.GetTrueVSize(), (real_t) 0.0),
|
||||
fespace(f), M(NULL), K(NULL), T(NULL), current_dt(0.0), z(height)
|
||||
{
|
||||
const double rel_tol = 1e-8;
|
||||
const real_t rel_tol = 1e-8;
|
||||
|
||||
fespace.GetEssentialTrueDofs(ess_bdr, ess_tdof_list);
|
||||
|
||||
@@ -132,7 +131,7 @@ void WaveOperator::Mult(const Vector &u, const Vector &du_dt,
|
||||
M_solver.Mult(z, d2udt2);
|
||||
}
|
||||
|
||||
void WaveOperator::ImplicitSolve(const double fac0, const double fac1,
|
||||
void WaveOperator::ImplicitSolve(const real_t fac0, const real_t fac1,
|
||||
const Vector &u, const Vector &dudt, Vector &d2udt2)
|
||||
{
|
||||
// Solve the equation:
|
||||
@@ -167,12 +166,12 @@ WaveOperator::~WaveOperator()
|
||||
delete c2;
|
||||
}
|
||||
|
||||
double InitialSolution(const Vector &x)
|
||||
real_t InitialSolution(const Vector &x)
|
||||
{
|
||||
return exp(-x.Norml2()*x.Norml2()*30);
|
||||
}
|
||||
|
||||
double InitialRate(const Vector &x)
|
||||
real_t InitialRate(const Vector &x)
|
||||
{
|
||||
return 0.0;
|
||||
}
|
||||
@@ -186,9 +185,9 @@ int main(int argc, char *argv[])
|
||||
int ref_levels = 2;
|
||||
int order = 2;
|
||||
int ode_solver_type = 10;
|
||||
double t_final = 0.5;
|
||||
double dt = 1.0e-2;
|
||||
double speed = 1.0;
|
||||
real_t t_final = 0.5;
|
||||
real_t dt = 1.0e-2;
|
||||
real_t speed = 1.0;
|
||||
bool visualization = true;
|
||||
bool visit = true;
|
||||
bool dirichlet = true;
|
||||
@@ -366,7 +365,7 @@ int main(int argc, char *argv[])
|
||||
// 8. Perform time-integration (looping over the time iterations, ti, with a
|
||||
// time-step dt).
|
||||
ode_solver->Init(oper);
|
||||
double t = 0.0;
|
||||
real_t t = 0.0;
|
||||
|
||||
bool last_step = false;
|
||||
for (int ti = 1; !last_step; ti++)
|
||||
|
||||
+14
-14
@@ -44,14 +44,14 @@
|
||||
using namespace std;
|
||||
using namespace mfem;
|
||||
|
||||
double p_exact(const Vector &x);
|
||||
real_t p_exact(const Vector &x);
|
||||
void gradp_exact(const Vector &, Vector &);
|
||||
double div_gradp_exact(const Vector &x);
|
||||
real_t div_gradp_exact(const Vector &x);
|
||||
void v_exact(const Vector &x, Vector &v);
|
||||
void curlv_exact(const Vector &x, Vector &cv);
|
||||
|
||||
int dim;
|
||||
double freq = 1.0, kappa;
|
||||
real_t freq = 1.0, kappa;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
@@ -304,9 +304,9 @@ int main(int argc, char *argv[])
|
||||
// 12. Compute and print the L_2 norm of the error.
|
||||
if (prob == 0)
|
||||
{
|
||||
double errSol = x.ComputeL2Error(gradp_coef);
|
||||
double errInterp = discreteInterpolant.ComputeL2Error(gradp_coef);
|
||||
double errProj = exact_proj.ComputeL2Error(gradp_coef);
|
||||
real_t errSol = x.ComputeL2Error(gradp_coef);
|
||||
real_t errInterp = discreteInterpolant.ComputeL2Error(gradp_coef);
|
||||
real_t errProj = exact_proj.ComputeL2Error(gradp_coef);
|
||||
|
||||
cout << "\n Solution of (E_h,v) = (grad p_h,v) for E_h and v in H(curl): "
|
||||
"|| E_h - grad p ||_{L_2} = " << errSol << '\n' << endl;
|
||||
@@ -317,9 +317,9 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
else if (prob == 1)
|
||||
{
|
||||
double errSol = x.ComputeL2Error(curlv_coef);
|
||||
double errInterp = discreteInterpolant.ComputeL2Error(curlv_coef);
|
||||
double errProj = exact_proj.ComputeL2Error(curlv_coef);
|
||||
real_t errSol = x.ComputeL2Error(curlv_coef);
|
||||
real_t errInterp = discreteInterpolant.ComputeL2Error(curlv_coef);
|
||||
real_t errProj = exact_proj.ComputeL2Error(curlv_coef);
|
||||
|
||||
cout << "\n Solution of (E_h,w) = (curl v_h,w) for E_h and w in H(div): "
|
||||
"|| E_h - curl v ||_{L_2} = " << errSol << '\n' << endl;
|
||||
@@ -337,9 +337,9 @@ int main(int argc, char *argv[])
|
||||
irs[i] = &(IntRules.Get(i, order_quad));
|
||||
}
|
||||
|
||||
double errSol = x.ComputeL2Error(divgradp_coef, irs);
|
||||
double errInterp = discreteInterpolant.ComputeL2Error(divgradp_coef, irs);
|
||||
double errProj = exact_proj.ComputeL2Error(divgradp_coef, irs);
|
||||
real_t errSol = x.ComputeL2Error(divgradp_coef, irs);
|
||||
real_t errInterp = discreteInterpolant.ComputeL2Error(divgradp_coef, irs);
|
||||
real_t errProj = exact_proj.ComputeL2Error(divgradp_coef, irs);
|
||||
|
||||
cout << "\n Solution of (f_h,q) = (div v_h,q) for f_h and q in L_2: "
|
||||
"|| f_h - div v ||_{L_2} = " << errSol << '\n' << endl;
|
||||
@@ -376,7 +376,7 @@ int main(int argc, char *argv[])
|
||||
return 0;
|
||||
}
|
||||
|
||||
double p_exact(const Vector &x)
|
||||
real_t p_exact(const Vector &x)
|
||||
{
|
||||
if (dim == 3)
|
||||
{
|
||||
@@ -406,7 +406,7 @@ void gradp_exact(const Vector &x, Vector &f)
|
||||
}
|
||||
}
|
||||
|
||||
double div_gradp_exact(const Vector &x)
|
||||
real_t div_gradp_exact(const Vector &x)
|
||||
{
|
||||
if (dim == 3)
|
||||
{
|
||||
|
||||
+14
-14
@@ -44,14 +44,14 @@
|
||||
using namespace std;
|
||||
using namespace mfem;
|
||||
|
||||
double p_exact(const Vector &x);
|
||||
real_t p_exact(const Vector &x);
|
||||
void gradp_exact(const Vector &, Vector &);
|
||||
double div_gradp_exact(const Vector &x);
|
||||
real_t div_gradp_exact(const Vector &x);
|
||||
void v_exact(const Vector &x, Vector &v);
|
||||
void curlv_exact(const Vector &x, Vector &cv);
|
||||
|
||||
int dim;
|
||||
double freq = 1.0, kappa;
|
||||
real_t freq = 1.0, kappa;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
@@ -352,9 +352,9 @@ int main(int argc, char *argv[])
|
||||
// 14. Compute and print the L_2 norm of the error.
|
||||
if (prob == 0)
|
||||
{
|
||||
double errSol = x.ComputeL2Error(gradp_coef);
|
||||
double errInterp = discreteInterpolant.ComputeL2Error(gradp_coef);
|
||||
double errProj = exact_proj.ComputeL2Error(gradp_coef);
|
||||
real_t errSol = x.ComputeL2Error(gradp_coef);
|
||||
real_t errInterp = discreteInterpolant.ComputeL2Error(gradp_coef);
|
||||
real_t errProj = exact_proj.ComputeL2Error(gradp_coef);
|
||||
|
||||
if (myid == 0)
|
||||
{
|
||||
@@ -368,9 +368,9 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
else if (prob == 1)
|
||||
{
|
||||
double errSol = x.ComputeL2Error(curlv_coef);
|
||||
double errInterp = discreteInterpolant.ComputeL2Error(curlv_coef);
|
||||
double errProj = exact_proj.ComputeL2Error(curlv_coef);
|
||||
real_t errSol = x.ComputeL2Error(curlv_coef);
|
||||
real_t errInterp = discreteInterpolant.ComputeL2Error(curlv_coef);
|
||||
real_t errProj = exact_proj.ComputeL2Error(curlv_coef);
|
||||
|
||||
if (myid == 0)
|
||||
{
|
||||
@@ -391,9 +391,9 @@ int main(int argc, char *argv[])
|
||||
irs[i] = &(IntRules.Get(i, order_quad));
|
||||
}
|
||||
|
||||
double errSol = x.ComputeL2Error(divgradp_coef, irs);
|
||||
double errInterp = discreteInterpolant.ComputeL2Error(divgradp_coef, irs);
|
||||
double errProj = exact_proj.ComputeL2Error(divgradp_coef, irs);
|
||||
real_t errSol = x.ComputeL2Error(divgradp_coef, irs);
|
||||
real_t errInterp = discreteInterpolant.ComputeL2Error(divgradp_coef, irs);
|
||||
real_t errProj = exact_proj.ComputeL2Error(divgradp_coef, irs);
|
||||
|
||||
if (myid == 0)
|
||||
{
|
||||
@@ -441,7 +441,7 @@ int main(int argc, char *argv[])
|
||||
return 0;
|
||||
}
|
||||
|
||||
double p_exact(const Vector &x)
|
||||
real_t p_exact(const Vector &x)
|
||||
{
|
||||
if (dim == 3)
|
||||
{
|
||||
@@ -471,7 +471,7 @@ void gradp_exact(const Vector &x, Vector &f)
|
||||
}
|
||||
}
|
||||
|
||||
double div_gradp_exact(const Vector &x)
|
||||
real_t div_gradp_exact(const Vector &x)
|
||||
{
|
||||
if (dim == 3)
|
||||
{
|
||||
|
||||
+101
-101
@@ -53,13 +53,13 @@ private:
|
||||
int dim;
|
||||
|
||||
// Length of the PML Region in each direction
|
||||
Array2D<double> length;
|
||||
Array2D<real_t> length;
|
||||
|
||||
// Computational Domain Boundary
|
||||
Array2D<double> comp_dom_bdr;
|
||||
Array2D<real_t> comp_dom_bdr;
|
||||
|
||||
// Domain Boundary
|
||||
Array2D<double> dom_bdr;
|
||||
Array2D<real_t> dom_bdr;
|
||||
|
||||
// Integer Array identifying elements in the PML
|
||||
// 0: in the PML, 1: not in the PML
|
||||
@@ -70,13 +70,13 @@ private:
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
PML(Mesh *mesh_,Array2D<double> length_);
|
||||
PML(Mesh *mesh_,Array2D<real_t> length_);
|
||||
|
||||
// Return Computational Domain Boundary
|
||||
Array2D<double> GetCompDomainBdr() {return comp_dom_bdr;}
|
||||
Array2D<real_t> GetCompDomainBdr() {return comp_dom_bdr;}
|
||||
|
||||
// Return Domain Boundary
|
||||
Array2D<double> GetDomainBdr() {return dom_bdr;}
|
||||
Array2D<real_t> GetDomainBdr() {return dom_bdr;}
|
||||
|
||||
// Return Markers list for elements
|
||||
Array<int> * GetMarkedPMLElements() {return &elems;}
|
||||
@@ -85,7 +85,7 @@ public:
|
||||
void SetAttributes(Mesh *mesh_);
|
||||
|
||||
// PML complex stretching function
|
||||
void StretchFunction(const Vector &x, vector<complex<double>> &dxs);
|
||||
void StretchFunction(const Vector &x, vector<complex<real_t>> &dxs);
|
||||
};
|
||||
|
||||
// Class for returning the PML coefficients of the bilinear form
|
||||
@@ -106,7 +106,7 @@ public:
|
||||
virtual void Eval(Vector &K, ElementTransformation &T,
|
||||
const IntegrationPoint &ip)
|
||||
{
|
||||
double x[3];
|
||||
real_t x[3];
|
||||
Vector transip(x, 3);
|
||||
T.Transform(ip, transip);
|
||||
K.SetSize(vdim);
|
||||
@@ -114,7 +114,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
void maxwell_solution(const Vector &x, vector<complex<double>> &Eval);
|
||||
void maxwell_solution(const Vector &x, vector<complex<real_t>> &Eval);
|
||||
|
||||
void E_bdr_data_Re(const Vector &x, Vector &E);
|
||||
void E_bdr_data_Im(const Vector &x, Vector &E);
|
||||
@@ -134,12 +134,12 @@ void detJ_inv_JT_J_Re(const Vector &x, PML * pml, Vector &D);
|
||||
void detJ_inv_JT_J_Im(const Vector &x, PML * pml, Vector &D);
|
||||
void detJ_inv_JT_J_abs(const Vector &x, PML * pml, Vector &D);
|
||||
|
||||
Array2D<double> comp_domain_bdr;
|
||||
Array2D<double> domain_bdr;
|
||||
Array2D<real_t> comp_domain_bdr;
|
||||
Array2D<real_t> domain_bdr;
|
||||
|
||||
double mu = 1.0;
|
||||
double epsilon = 1.0;
|
||||
double omega;
|
||||
real_t mu = 1.0;
|
||||
real_t epsilon = 1.0;
|
||||
real_t omega;
|
||||
int dim;
|
||||
bool exact_known = false;
|
||||
|
||||
@@ -160,7 +160,7 @@ int main(int argc, char *argv[])
|
||||
int order = 1;
|
||||
int ref_levels = 3;
|
||||
int iprob = 4;
|
||||
double freq = 5.0;
|
||||
real_t freq = 5.0;
|
||||
bool herm_conv = true;
|
||||
bool umf_solver = false;
|
||||
bool visualization = 1;
|
||||
@@ -244,7 +244,7 @@ int main(int argc, char *argv[])
|
||||
omega = 2.0 * M_PI * freq;
|
||||
|
||||
// Setup PML length
|
||||
Array2D<double> length(dim, 2); length = 0.0;
|
||||
Array2D<real_t> length(dim, 2); length = 0.0;
|
||||
|
||||
// 4. Setup the Cartesian PML region.
|
||||
switch (prob)
|
||||
@@ -470,7 +470,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
std::unique_ptr<Operator> pc_r;
|
||||
std::unique_ptr<Operator> pc_i;
|
||||
double s = (conv == ComplexOperator::HERMITIAN) ? -1.0 : 1.0;
|
||||
real_t s = (conv == ComplexOperator::HERMITIAN) ? -1.0 : 1.0;
|
||||
if (pa)
|
||||
{
|
||||
// Jacobi Smoother
|
||||
@@ -519,14 +519,14 @@ int main(int argc, char *argv[])
|
||||
irs[i] = &(IntRules.Get(i, order_quad));
|
||||
}
|
||||
|
||||
double L2Error_Re = x.real().ComputeL2Error(E_ex_Re, irs,
|
||||
real_t L2Error_Re = x.real().ComputeL2Error(E_ex_Re, irs,
|
||||
pml->GetMarkedPMLElements());
|
||||
double L2Error_Im = x.imag().ComputeL2Error(E_ex_Im, irs,
|
||||
real_t L2Error_Im = x.imag().ComputeL2Error(E_ex_Im, irs,
|
||||
pml->GetMarkedPMLElements());
|
||||
|
||||
ComplexGridFunction x_gf0(fespace);
|
||||
x_gf0 = 0.0;
|
||||
double norm_E_Re, norm_E_Im;
|
||||
real_t norm_E_Re, norm_E_Im;
|
||||
norm_E_Re = x_gf0.real().ComputeL2Error(E_ex_Re, irs,
|
||||
pml->GetMarkedPMLElements());
|
||||
norm_E_Im = x_gf0.imag().ComputeL2Error(E_ex_Im, irs,
|
||||
@@ -593,7 +593,7 @@ int main(int argc, char *argv[])
|
||||
int i = 0;
|
||||
while (sol_sock)
|
||||
{
|
||||
double t = (double)(i % num_frames) / num_frames;
|
||||
real_t t = (real_t)(i % num_frames) / num_frames;
|
||||
ostringstream oss;
|
||||
oss << "Harmonic Solution (t = " << t << " T)";
|
||||
|
||||
@@ -617,20 +617,20 @@ int main(int argc, char *argv[])
|
||||
void source(const Vector &x, Vector &f)
|
||||
{
|
||||
Vector center(dim);
|
||||
double r = 0.0;
|
||||
real_t r = 0.0;
|
||||
for (int i = 0; i < dim; ++i)
|
||||
{
|
||||
center(i) = 0.5 * (comp_domain_bdr(i, 0) + comp_domain_bdr(i, 1));
|
||||
r += pow(x[i] - center[i], 2.);
|
||||
}
|
||||
double n = 5.0 * omega * sqrt(epsilon * mu) / M_PI;
|
||||
double coeff = pow(n, 2) / M_PI;
|
||||
double alpha = -pow(n, 2) * r;
|
||||
real_t n = 5.0 * omega * sqrt(epsilon * mu) / M_PI;
|
||||
real_t coeff = pow(n, 2) / M_PI;
|
||||
real_t alpha = -pow(n, 2) * r;
|
||||
f = 0.0;
|
||||
f[0] = coeff * exp(alpha);
|
||||
}
|
||||
|
||||
void maxwell_solution(const Vector &x, vector<complex<double>> &E)
|
||||
void maxwell_solution(const Vector &x, vector<complex<real_t>> &E)
|
||||
{
|
||||
// Initialize
|
||||
for (int i = 0; i < dim; ++i)
|
||||
@@ -638,8 +638,8 @@ void maxwell_solution(const Vector &x, vector<complex<double>> &E)
|
||||
E[i] = 0.0;
|
||||
}
|
||||
|
||||
complex<double> zi = complex<double>(0., 1.);
|
||||
double k = omega * sqrt(epsilon * mu);
|
||||
complex<real_t> zi = complex<real_t>(0., 1.);
|
||||
real_t k = omega * sqrt(epsilon * mu);
|
||||
switch (prob)
|
||||
{
|
||||
case disc:
|
||||
@@ -654,58 +654,58 @@ void maxwell_solution(const Vector &x, vector<complex<double>> &E)
|
||||
|
||||
if (dim == 2)
|
||||
{
|
||||
double x0 = x(0) + shift(0);
|
||||
double x1 = x(1) + shift(1);
|
||||
double r = sqrt(x0 * x0 + x1 * x1);
|
||||
double beta = k * r;
|
||||
real_t x0 = x(0) + shift(0);
|
||||
real_t x1 = x(1) + shift(1);
|
||||
real_t r = sqrt(x0 * x0 + x1 * x1);
|
||||
real_t beta = k * r;
|
||||
|
||||
// Bessel functions
|
||||
complex<double> Ho, Ho_r, Ho_rr;
|
||||
Ho = jn(0, beta) + zi * yn(0, beta);
|
||||
Ho_r = -k * (jn(1, beta) + zi * yn(1, beta));
|
||||
Ho_rr = -k * k * (1.0 / beta *
|
||||
(jn(1, beta) + zi * yn(1, beta)) -
|
||||
(jn(2, beta) + zi * yn(2, beta)));
|
||||
complex<real_t> Ho, Ho_r, Ho_rr;
|
||||
Ho = jn(0, beta) + (complex<double>) zi * yn(0, beta);
|
||||
Ho_r = -k * complex<real_t>(jn(1, beta) + (complex<double>) zi * yn(1, beta));
|
||||
Ho_rr = -k * k * (real_t(1) / beta *
|
||||
complex<real_t>(jn(1, beta) + (complex<double>) zi * yn(1, beta)) -
|
||||
complex<real_t>(jn(2, beta) + (complex<double>) zi * yn(2, beta)));
|
||||
|
||||
// First derivatives
|
||||
double r_x = x0 / r;
|
||||
double r_y = x1 / r;
|
||||
double r_xy = -(r_x / r) * r_y;
|
||||
double r_xx = (1.0 / r) * (1.0 - r_x * r_x);
|
||||
real_t r_x = x0 / r;
|
||||
real_t r_y = x1 / r;
|
||||
real_t r_xy = -(r_x / r) * r_y;
|
||||
real_t r_xx = (1.0 / r) * (1.0 - r_x * r_x);
|
||||
|
||||
complex<double> val, val_xx, val_xy;
|
||||
val = 0.25 * zi * Ho;
|
||||
val_xx = 0.25 * zi * (r_xx * Ho_r + r_x * r_x * Ho_rr);
|
||||
val_xy = 0.25 * zi * (r_xy * Ho_r + r_x * r_y * Ho_rr);
|
||||
complex<real_t> val, val_xx, val_xy;
|
||||
val = real_t(0.25) * zi * Ho;
|
||||
val_xx = real_t(0.25) * zi * (r_xx * Ho_r + r_x * r_x * Ho_rr);
|
||||
val_xy = real_t(0.25) * zi * (r_xy * Ho_r + r_x * r_y * Ho_rr);
|
||||
E[0] = zi / k * (k * k * val + val_xx);
|
||||
E[1] = zi / k * val_xy;
|
||||
}
|
||||
else if (dim == 3)
|
||||
{
|
||||
double x0 = x(0) + shift(0);
|
||||
double x1 = x(1) + shift(1);
|
||||
double x2 = x(2) + shift(2);
|
||||
double r = sqrt(x0 * x0 + x1 * x1 + x2 * x2);
|
||||
real_t x0 = x(0) + shift(0);
|
||||
real_t x1 = x(1) + shift(1);
|
||||
real_t x2 = x(2) + shift(2);
|
||||
real_t r = sqrt(x0 * x0 + x1 * x1 + x2 * x2);
|
||||
|
||||
double r_x = x0 / r;
|
||||
double r_y = x1 / r;
|
||||
double r_z = x2 / r;
|
||||
double r_xx = (1.0 / r) * (1.0 - r_x * r_x);
|
||||
double r_yx = -(r_y / r) * r_x;
|
||||
double r_zx = -(r_z / r) * r_x;
|
||||
real_t r_x = x0 / r;
|
||||
real_t r_y = x1 / r;
|
||||
real_t r_z = x2 / r;
|
||||
real_t r_xx = (1.0 / r) * (1.0 - r_x * r_x);
|
||||
real_t r_yx = -(r_y / r) * r_x;
|
||||
real_t r_zx = -(r_z / r) * r_x;
|
||||
|
||||
complex<double> val, val_r, val_rr;
|
||||
complex<real_t> val, val_r, val_rr;
|
||||
val = exp(zi * k * r) / r;
|
||||
val_r = val / r * (zi * k * r - 1.0);
|
||||
val_r = val / r * (zi * k * r - real_t(1));
|
||||
val_rr = val / (r * r) * (-k * k * r * r
|
||||
- 2.0 * zi * k * r + 2.0);
|
||||
- real_t(2) * zi * k * r + real_t(2));
|
||||
|
||||
complex<double> val_xx, val_yx, val_zx;
|
||||
complex<real_t> val_xx, val_yx, val_zx;
|
||||
val_xx = val_rr * r_x * r_x + val_r * r_xx;
|
||||
val_yx = val_rr * r_x * r_y + val_r * r_yx;
|
||||
val_zx = val_rr * r_x * r_z + val_r * r_zx;
|
||||
|
||||
complex<double> alpha = zi * k / 4.0 / M_PI / k / k;
|
||||
complex<real_t> alpha = zi * k / real_t(4) / (real_t) M_PI / k / k;
|
||||
E[0] = alpha * (k * k * val + val_xx);
|
||||
E[1] = alpha * val_yx;
|
||||
E[2] = alpha * val_zx;
|
||||
@@ -717,12 +717,12 @@ void maxwell_solution(const Vector &x, vector<complex<double>> &E)
|
||||
// T_10 mode
|
||||
if (dim == 3)
|
||||
{
|
||||
double k10 = sqrt(k * k - M_PI * M_PI);
|
||||
E[1] = -zi * k / M_PI * sin(M_PI*x(2))*exp(zi * k10 * x(0));
|
||||
real_t k10 = sqrt(k * k - M_PI * M_PI);
|
||||
E[1] = -zi * k / (real_t) M_PI * sin((real_t) M_PI*x(2))*exp(zi * k10 * x(0));
|
||||
}
|
||||
else if (dim == 2)
|
||||
{
|
||||
E[1] = -zi * k / M_PI * exp(zi * k * x(0));
|
||||
E[1] = -zi * k / (real_t) M_PI * exp(zi * k * x(0));
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -733,7 +733,7 @@ void maxwell_solution(const Vector &x, vector<complex<double>> &E)
|
||||
|
||||
void E_exact_Re(const Vector &x, Vector &E)
|
||||
{
|
||||
vector<complex<double>> Eval(E.Size());
|
||||
vector<complex<real_t>> Eval(E.Size());
|
||||
maxwell_solution(x, Eval);
|
||||
for (int i = 0; i < dim; ++i)
|
||||
{
|
||||
@@ -743,7 +743,7 @@ void E_exact_Re(const Vector &x, Vector &E)
|
||||
|
||||
void E_exact_Im(const Vector &x, Vector &E)
|
||||
{
|
||||
vector<complex<double>> Eval(E.Size());
|
||||
vector<complex<real_t>> Eval(E.Size());
|
||||
maxwell_solution(x, Eval);
|
||||
for (int i = 0; i < dim; ++i)
|
||||
{
|
||||
@@ -768,7 +768,7 @@ void E_bdr_data_Re(const Vector &x, Vector &E)
|
||||
}
|
||||
if (!in_pml)
|
||||
{
|
||||
vector<complex<double>> Eval(E.Size());
|
||||
vector<complex<real_t>> Eval(E.Size());
|
||||
maxwell_solution(x, Eval);
|
||||
for (int i = 0; i < dim; ++i)
|
||||
{
|
||||
@@ -795,7 +795,7 @@ void E_bdr_data_Im(const Vector &x, Vector &E)
|
||||
}
|
||||
if (!in_pml)
|
||||
{
|
||||
vector<complex<double>> Eval(E.Size());
|
||||
vector<complex<real_t>> Eval(E.Size());
|
||||
maxwell_solution(x, Eval);
|
||||
for (int i = 0; i < dim; ++i)
|
||||
{
|
||||
@@ -806,8 +806,8 @@ void E_bdr_data_Im(const Vector &x, Vector &E)
|
||||
|
||||
void detJ_JT_J_inv_Re(const Vector &x, PML * pml, Vector &D)
|
||||
{
|
||||
vector<complex<double>> dxs(dim);
|
||||
complex<double> det(1.0, 0.0);
|
||||
vector<complex<real_t>> dxs(dim);
|
||||
complex<real_t> det(1.0, 0.0);
|
||||
pml->StretchFunction(x, dxs);
|
||||
|
||||
for (int i = 0; i < dim; ++i)
|
||||
@@ -817,14 +817,14 @@ void detJ_JT_J_inv_Re(const Vector &x, PML * pml, Vector &D)
|
||||
|
||||
for (int i = 0; i < dim; ++i)
|
||||
{
|
||||
D(i) = (det / pow(dxs[i], 2)).real();
|
||||
D(i) = (det / pow(dxs[i], real_t(2))).real();
|
||||
}
|
||||
}
|
||||
|
||||
void detJ_JT_J_inv_Im(const Vector &x, PML * pml, Vector &D)
|
||||
{
|
||||
vector<complex<double>> dxs(dim);
|
||||
complex<double> det = 1.0;
|
||||
vector<complex<real_t>> dxs(dim);
|
||||
complex<real_t> det = 1.0;
|
||||
pml->StretchFunction(x, dxs);
|
||||
|
||||
for (int i = 0; i < dim; ++i)
|
||||
@@ -834,14 +834,14 @@ void detJ_JT_J_inv_Im(const Vector &x, PML * pml, Vector &D)
|
||||
|
||||
for (int i = 0; i < dim; ++i)
|
||||
{
|
||||
D(i) = (det / pow(dxs[i], 2)).imag();
|
||||
D(i) = (det / pow(dxs[i], real_t(2))).imag();
|
||||
}
|
||||
}
|
||||
|
||||
void detJ_JT_J_inv_abs(const Vector &x, PML * pml, Vector &D)
|
||||
{
|
||||
vector<complex<double>> dxs(dim);
|
||||
complex<double> det = 1.0;
|
||||
vector<complex<real_t>> dxs(dim);
|
||||
complex<real_t> det = 1.0;
|
||||
pml->StretchFunction(x, dxs);
|
||||
|
||||
for (int i = 0; i < dim; ++i)
|
||||
@@ -851,14 +851,14 @@ void detJ_JT_J_inv_abs(const Vector &x, PML * pml, Vector &D)
|
||||
|
||||
for (int i = 0; i < dim; ++i)
|
||||
{
|
||||
D(i) = abs(det / pow(dxs[i], 2));
|
||||
D(i) = abs(det / pow(dxs[i], real_t(2)));
|
||||
}
|
||||
}
|
||||
|
||||
void detJ_inv_JT_J_Re(const Vector &x, PML * pml, Vector &D)
|
||||
{
|
||||
vector<complex<double>> dxs(dim);
|
||||
complex<double> det(1.0, 0.0);
|
||||
vector<complex<real_t>> dxs(dim);
|
||||
complex<real_t> det(1.0, 0.0);
|
||||
pml->StretchFunction(x, dxs);
|
||||
|
||||
for (int i = 0; i < dim; ++i)
|
||||
@@ -869,21 +869,21 @@ void detJ_inv_JT_J_Re(const Vector &x, PML * pml, Vector &D)
|
||||
// in the 2D case the coefficient is scalar 1/det(J)
|
||||
if (dim == 2)
|
||||
{
|
||||
D = (1.0 / det).real();
|
||||
D = (real_t(1) / det).real();
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < dim; ++i)
|
||||
{
|
||||
D(i) = (pow(dxs[i], 2) / det).real();
|
||||
D(i) = (pow(dxs[i], real_t(2)) / det).real();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void detJ_inv_JT_J_Im(const Vector &x, PML * pml, Vector &D)
|
||||
{
|
||||
vector<complex<double>> dxs(dim);
|
||||
complex<double> det = 1.0;
|
||||
vector<complex<real_t>> dxs(dim);
|
||||
complex<real_t> det = 1.0;
|
||||
pml->StretchFunction(x, dxs);
|
||||
|
||||
for (int i = 0; i < dim; ++i)
|
||||
@@ -893,21 +893,21 @@ void detJ_inv_JT_J_Im(const Vector &x, PML * pml, Vector &D)
|
||||
|
||||
if (dim == 2)
|
||||
{
|
||||
D = (1.0 / det).imag();
|
||||
D = (real_t(1) / det).imag();
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < dim; ++i)
|
||||
{
|
||||
D(i) = (pow(dxs[i], 2) / det).imag();
|
||||
D(i) = (pow(dxs[i], real_t(2)) / det).imag();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void detJ_inv_JT_J_abs(const Vector &x, PML * pml, Vector &D)
|
||||
{
|
||||
vector<complex<double>> dxs(dim);
|
||||
complex<double> det = 1.0;
|
||||
vector<complex<real_t>> dxs(dim);
|
||||
complex<real_t> det = 1.0;
|
||||
pml->StretchFunction(x, dxs);
|
||||
|
||||
for (int i = 0; i < dim; ++i)
|
||||
@@ -917,18 +917,18 @@ void detJ_inv_JT_J_abs(const Vector &x, PML * pml, Vector &D)
|
||||
|
||||
if (dim == 2)
|
||||
{
|
||||
D = abs(1.0 / det);
|
||||
D = abs(real_t(1) / det);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < dim; ++i)
|
||||
{
|
||||
D(i) = abs(pow(dxs[i], 2) / det);
|
||||
D(i) = abs(pow(dxs[i], real_t(2)) / det);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PML::PML(Mesh *mesh_, Array2D<double> length_)
|
||||
PML::PML(Mesh *mesh_, Array2D<real_t> length_)
|
||||
: mesh(mesh_), length(length_)
|
||||
{
|
||||
dim = mesh->Dimension();
|
||||
@@ -979,7 +979,7 @@ void PML::SetAttributes(Mesh *mesh_)
|
||||
for (int iv = 0; iv < nrvert; ++iv)
|
||||
{
|
||||
int vert_idx = vertices[iv];
|
||||
double *coords = mesh_->GetVertex(vert_idx);
|
||||
real_t *coords = mesh_->GetVertex(vert_idx);
|
||||
for (int comp = 0; comp < dim; ++comp)
|
||||
{
|
||||
if (coords[comp] > comp_dom_bdr(comp, 1) ||
|
||||
@@ -1000,14 +1000,14 @@ void PML::SetAttributes(Mesh *mesh_)
|
||||
}
|
||||
|
||||
void PML::StretchFunction(const Vector &x,
|
||||
vector<complex<double>> &dxs)
|
||||
vector<complex<real_t>> &dxs)
|
||||
{
|
||||
complex<double> zi = complex<double>(0., 1.);
|
||||
complex<real_t> zi = complex<real_t>(0., 1.);
|
||||
|
||||
double n = 2.0;
|
||||
double c = 5.0;
|
||||
double coeff;
|
||||
double k = omega * sqrt(epsilon * mu);
|
||||
real_t n = 2.0;
|
||||
real_t c = 5.0;
|
||||
real_t coeff;
|
||||
real_t k = omega * sqrt(epsilon * mu);
|
||||
|
||||
// Stretch in each direction independently
|
||||
for (int i = 0; i < dim; ++i)
|
||||
@@ -1016,14 +1016,14 @@ void PML::StretchFunction(const Vector &x,
|
||||
if (x(i) >= comp_domain_bdr(i, 1))
|
||||
{
|
||||
coeff = n * c / k / pow(length(i, 1), n);
|
||||
dxs[i] = 1.0 + zi * coeff *
|
||||
abs(pow(x(i) - comp_domain_bdr(i, 1), n - 1.0));
|
||||
dxs[i] = real_t(1) + zi * coeff *
|
||||
abs(pow(x(i) - comp_domain_bdr(i, 1), n - real_t(1)));
|
||||
}
|
||||
if (x(i) <= comp_domain_bdr(i, 0))
|
||||
{
|
||||
coeff = n * c / k / pow(length(i, 0), n);
|
||||
dxs[i] = 1.0 + zi * coeff *
|
||||
abs(pow(x(i) - comp_domain_bdr(i, 0), n - 1.0));
|
||||
dxs[i] = real_t(1) + zi * coeff *
|
||||
abs(pow(x(i) - comp_domain_bdr(i, 0), n - real_t(1)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+100
-100
@@ -52,13 +52,13 @@ private:
|
||||
int dim;
|
||||
|
||||
// Length of the PML Region in each direction
|
||||
Array2D<double> length;
|
||||
Array2D<real_t> length;
|
||||
|
||||
// Computational Domain Boundary
|
||||
Array2D<double> comp_dom_bdr;
|
||||
Array2D<real_t> comp_dom_bdr;
|
||||
|
||||
// Domain Boundary
|
||||
Array2D<double> dom_bdr;
|
||||
Array2D<real_t> dom_bdr;
|
||||
|
||||
// Integer Array identifying elements in the PML
|
||||
// 0: in the PML, 1: not in the PML
|
||||
@@ -69,13 +69,13 @@ private:
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
PML(Mesh *mesh_,Array2D<double> length_);
|
||||
PML(Mesh *mesh_,Array2D<real_t> length_);
|
||||
|
||||
// Return Computational Domain Boundary
|
||||
Array2D<double> GetCompDomainBdr() {return comp_dom_bdr;}
|
||||
Array2D<real_t> GetCompDomainBdr() {return comp_dom_bdr;}
|
||||
|
||||
// Return Domain Boundary
|
||||
Array2D<double> GetDomainBdr() {return dom_bdr;}
|
||||
Array2D<real_t> GetDomainBdr() {return dom_bdr;}
|
||||
|
||||
// Return Markers list for elements
|
||||
Array<int> * GetMarkedPMLElements() {return &elems;}
|
||||
@@ -84,7 +84,7 @@ public:
|
||||
void SetAttributes(ParMesh *pmesh);
|
||||
|
||||
// PML complex stretching function
|
||||
void StretchFunction(const Vector &x, vector<complex<double>> &dxs);
|
||||
void StretchFunction(const Vector &x, vector<complex<real_t>> &dxs);
|
||||
};
|
||||
|
||||
// Class for returning the PML coefficients of the bilinear form
|
||||
@@ -105,7 +105,7 @@ public:
|
||||
virtual void Eval(Vector &K, ElementTransformation &T,
|
||||
const IntegrationPoint &ip)
|
||||
{
|
||||
double x[3];
|
||||
real_t x[3];
|
||||
Vector transip(x, 3);
|
||||
T.Transform(ip, transip);
|
||||
K.SetSize(vdim);
|
||||
@@ -113,7 +113,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
void maxwell_solution(const Vector &x, vector<complex<double>> &Eval);
|
||||
void maxwell_solution(const Vector &x, vector<complex<real_t>> &Eval);
|
||||
|
||||
void E_bdr_data_Re(const Vector &x, Vector &E);
|
||||
void E_bdr_data_Im(const Vector &x, Vector &E);
|
||||
@@ -133,12 +133,12 @@ void detJ_inv_JT_J_Re(const Vector &x, PML * pml, Vector & D);
|
||||
void detJ_inv_JT_J_Im(const Vector &x, PML * pml, Vector & D);
|
||||
void detJ_inv_JT_J_abs(const Vector &x, PML * pml, Vector & D);
|
||||
|
||||
Array2D<double> comp_domain_bdr;
|
||||
Array2D<double> domain_bdr;
|
||||
Array2D<real_t> comp_domain_bdr;
|
||||
Array2D<real_t> domain_bdr;
|
||||
|
||||
double mu = 1.0;
|
||||
double epsilon = 1.0;
|
||||
double omega;
|
||||
real_t mu = 1.0;
|
||||
real_t epsilon = 1.0;
|
||||
real_t omega;
|
||||
int dim;
|
||||
bool exact_known = false;
|
||||
|
||||
@@ -166,7 +166,7 @@ int main(int argc, char *argv[])
|
||||
int ref_levels = 1;
|
||||
int par_ref_levels = 2;
|
||||
int iprob = 4;
|
||||
double freq = 5.0;
|
||||
real_t freq = 5.0;
|
||||
bool herm_conv = true;
|
||||
bool slu_solver = false;
|
||||
bool mumps_solver = false;
|
||||
@@ -278,7 +278,7 @@ int main(int argc, char *argv[])
|
||||
omega = 2.0 * M_PI * freq;
|
||||
|
||||
// Setup PML length
|
||||
Array2D<double> length(dim, 2); length = 0.0;
|
||||
Array2D<real_t> length(dim, 2); length = 0.0;
|
||||
|
||||
// 5. Setup the Cartesian PML region.
|
||||
switch (prob)
|
||||
@@ -599,14 +599,14 @@ int main(int argc, char *argv[])
|
||||
irs[i] = &(IntRules.Get(i, order_quad));
|
||||
}
|
||||
|
||||
double L2Error_Re = x.real().ComputeL2Error(E_ex_Re, irs,
|
||||
real_t L2Error_Re = x.real().ComputeL2Error(E_ex_Re, irs,
|
||||
pml->GetMarkedPMLElements());
|
||||
double L2Error_Im = x.imag().ComputeL2Error(E_ex_Im, irs,
|
||||
real_t L2Error_Im = x.imag().ComputeL2Error(E_ex_Im, irs,
|
||||
pml->GetMarkedPMLElements());
|
||||
|
||||
ParComplexGridFunction x_gf0(fespace);
|
||||
x_gf0 = 0.0;
|
||||
double norm_E_Re, norm_E_Im;
|
||||
real_t norm_E_Re, norm_E_Im;
|
||||
norm_E_Re = x_gf0.real().ComputeL2Error(E_ex_Re, irs,
|
||||
pml->GetMarkedPMLElements());
|
||||
norm_E_Im = x_gf0.imag().ComputeL2Error(E_ex_Im, irs,
|
||||
@@ -694,7 +694,7 @@ int main(int argc, char *argv[])
|
||||
int i = 0;
|
||||
while (sol_sock)
|
||||
{
|
||||
double t = (double)(i % num_frames) / num_frames;
|
||||
real_t t = (real_t)(i % num_frames) / num_frames;
|
||||
ostringstream oss;
|
||||
oss << "Harmonic Solution (t = " << t << " T)";
|
||||
|
||||
@@ -718,20 +718,20 @@ int main(int argc, char *argv[])
|
||||
void source(const Vector &x, Vector &f)
|
||||
{
|
||||
Vector center(dim);
|
||||
double r = 0.0;
|
||||
real_t r = 0.0;
|
||||
for (int i = 0; i < dim; ++i)
|
||||
{
|
||||
center(i) = 0.5 * (comp_domain_bdr(i, 0) + comp_domain_bdr(i, 1));
|
||||
r += pow(x[i] - center[i], 2.);
|
||||
}
|
||||
double n = 5.0 * omega * sqrt(epsilon * mu) / M_PI;
|
||||
double coeff = pow(n, 2) / M_PI;
|
||||
double alpha = -pow(n, 2) * r;
|
||||
real_t n = 5.0 * omega * sqrt(epsilon * mu) / M_PI;
|
||||
real_t coeff = pow(n, 2) / M_PI;
|
||||
real_t alpha = -pow(n, 2) * r;
|
||||
f = 0.0;
|
||||
f[0] = coeff * exp(alpha);
|
||||
}
|
||||
|
||||
void maxwell_solution(const Vector &x, vector<complex<double>> &E)
|
||||
void maxwell_solution(const Vector &x, vector<complex<real_t>> &E)
|
||||
{
|
||||
// Initialize
|
||||
for (int i = 0; i < dim; ++i)
|
||||
@@ -739,8 +739,8 @@ void maxwell_solution(const Vector &x, vector<complex<double>> &E)
|
||||
E[i] = 0.0;
|
||||
}
|
||||
|
||||
complex<double> zi = complex<double>(0., 1.);
|
||||
double k = omega * sqrt(epsilon * mu);
|
||||
complex<real_t> zi = complex<real_t>(0., 1.);
|
||||
real_t k = omega * sqrt(epsilon * mu);
|
||||
switch (prob)
|
||||
{
|
||||
case disc:
|
||||
@@ -755,58 +755,58 @@ void maxwell_solution(const Vector &x, vector<complex<double>> &E)
|
||||
|
||||
if (dim == 2)
|
||||
{
|
||||
double x0 = x(0) + shift(0);
|
||||
double x1 = x(1) + shift(1);
|
||||
double r = sqrt(x0 * x0 + x1 * x1);
|
||||
double beta = k * r;
|
||||
real_t x0 = x(0) + shift(0);
|
||||
real_t x1 = x(1) + shift(1);
|
||||
real_t r = sqrt(x0 * x0 + x1 * x1);
|
||||
real_t beta = k * r;
|
||||
|
||||
// Bessel functions
|
||||
complex<double> Ho, Ho_r, Ho_rr;
|
||||
Ho = jn(0, beta) + zi * yn(0, beta);
|
||||
Ho_r = -k * (jn(1, beta) + zi * yn(1, beta));
|
||||
Ho_rr = -k * k * (1.0 / beta *
|
||||
(jn(1, beta) + zi * yn(1, beta)) -
|
||||
(jn(2, beta) + zi * yn(2, beta)));
|
||||
complex<real_t> Ho, Ho_r, Ho_rr;
|
||||
Ho = jn(0, beta) + (complex<double>) zi * yn(0, beta);
|
||||
Ho_r = -k * complex<real_t>(jn(1, beta) + (complex<double>) zi * yn(1, beta));
|
||||
Ho_rr = -k * k * complex<real_t>(1.0 / beta *
|
||||
(jn(1, beta) + (complex<double>) zi * yn(1, beta)) -
|
||||
(jn(2, beta) + (complex<double>) zi * yn(2, beta)));
|
||||
|
||||
// First derivatives
|
||||
double r_x = x0 / r;
|
||||
double r_y = x1 / r;
|
||||
double r_xy = -(r_x / r) * r_y;
|
||||
double r_xx = (1.0 / r) * (1.0 - r_x * r_x);
|
||||
real_t r_x = x0 / r;
|
||||
real_t r_y = x1 / r;
|
||||
real_t r_xy = -(r_x / r) * r_y;
|
||||
real_t r_xx = (1.0 / r) * (1.0 - r_x * r_x);
|
||||
|
||||
complex<double> val, val_xx, val_xy;
|
||||
val = 0.25 * zi * Ho;
|
||||
val_xx = 0.25 * zi * (r_xx * Ho_r + r_x * r_x * Ho_rr);
|
||||
val_xy = 0.25 * zi * (r_xy * Ho_r + r_x * r_y * Ho_rr);
|
||||
complex<real_t> val, val_xx, val_xy;
|
||||
val = real_t(0.25) * zi * Ho;
|
||||
val_xx = real_t(0.25) * zi * (r_xx * Ho_r + r_x * r_x * Ho_rr);
|
||||
val_xy = real_t(0.25) * zi * (r_xy * Ho_r + r_x * r_y * Ho_rr);
|
||||
E[0] = zi / k * (k * k * val + val_xx);
|
||||
E[1] = zi / k * val_xy;
|
||||
}
|
||||
else if (dim == 3)
|
||||
{
|
||||
double x0 = x(0) + shift(0);
|
||||
double x1 = x(1) + shift(1);
|
||||
double x2 = x(2) + shift(2);
|
||||
double r = sqrt(x0 * x0 + x1 * x1 + x2 * x2);
|
||||
real_t x0 = x(0) + shift(0);
|
||||
real_t x1 = x(1) + shift(1);
|
||||
real_t x2 = x(2) + shift(2);
|
||||
real_t r = sqrt(x0 * x0 + x1 * x1 + x2 * x2);
|
||||
|
||||
double r_x = x0 / r;
|
||||
double r_y = x1 / r;
|
||||
double r_z = x2 / r;
|
||||
double r_xx = (1.0 / r) * (1.0 - r_x * r_x);
|
||||
double r_yx = -(r_y / r) * r_x;
|
||||
double r_zx = -(r_z / r) * r_x;
|
||||
real_t r_x = x0 / r;
|
||||
real_t r_y = x1 / r;
|
||||
real_t r_z = x2 / r;
|
||||
real_t r_xx = (1.0 / r) * (1.0 - r_x * r_x);
|
||||
real_t r_yx = -(r_y / r) * r_x;
|
||||
real_t r_zx = -(r_z / r) * r_x;
|
||||
|
||||
complex<double> val, val_r, val_rr;
|
||||
complex<real_t> val, val_r, val_rr;
|
||||
val = exp(zi * k * r) / r;
|
||||
val_r = val / r * (zi * k * r - 1.0);
|
||||
val_r = val / r * (zi * k * r - real_t(1));
|
||||
val_rr = val / (r * r) * (-k * k * r * r
|
||||
- 2.0 * zi * k * r + 2.0);
|
||||
- real_t(2) * zi * k * r + real_t(2));
|
||||
|
||||
complex<double> val_xx, val_yx, val_zx;
|
||||
complex<real_t> val_xx, val_yx, val_zx;
|
||||
val_xx = val_rr * r_x * r_x + val_r * r_xx;
|
||||
val_yx = val_rr * r_x * r_y + val_r * r_yx;
|
||||
val_zx = val_rr * r_x * r_z + val_r * r_zx;
|
||||
|
||||
complex<double> alpha = zi * k / 4.0 / M_PI / k / k;
|
||||
complex<real_t> alpha = zi * k / real_t(4) / (real_t) M_PI / k / k;
|
||||
E[0] = alpha * (k * k * val + val_xx);
|
||||
E[1] = alpha * val_yx;
|
||||
E[2] = alpha * val_zx;
|
||||
@@ -818,12 +818,12 @@ void maxwell_solution(const Vector &x, vector<complex<double>> &E)
|
||||
// T_10 mode
|
||||
if (dim == 3)
|
||||
{
|
||||
double k10 = sqrt(k * k - M_PI * M_PI);
|
||||
E[1] = -zi * k / M_PI * sin(M_PI*x(2))*exp(zi * k10 * x(0));
|
||||
real_t k10 = sqrt(k * k - M_PI * M_PI);
|
||||
E[1] = -zi * k / (real_t) M_PI * sin((real_t) M_PI*x(2))*exp(zi * k10 * x(0));
|
||||
}
|
||||
else if (dim == 2)
|
||||
{
|
||||
E[1] = -zi * k / M_PI * exp(zi * k * x(0));
|
||||
E[1] = -zi * k / (real_t) M_PI * exp(zi * k * x(0));
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -834,7 +834,7 @@ void maxwell_solution(const Vector &x, vector<complex<double>> &E)
|
||||
|
||||
void E_exact_Re(const Vector &x, Vector &E)
|
||||
{
|
||||
vector<complex<double>> Eval(E.Size());
|
||||
vector<complex<real_t>> Eval(E.Size());
|
||||
maxwell_solution(x, Eval);
|
||||
for (int i = 0; i < dim; ++i)
|
||||
{
|
||||
@@ -844,7 +844,7 @@ void E_exact_Re(const Vector &x, Vector &E)
|
||||
|
||||
void E_exact_Im(const Vector &x, Vector &E)
|
||||
{
|
||||
vector<complex<double>> Eval(E.Size());
|
||||
vector<complex<real_t>> Eval(E.Size());
|
||||
maxwell_solution(x, Eval);
|
||||
for (int i = 0; i < dim; ++i)
|
||||
{
|
||||
@@ -869,7 +869,7 @@ void E_bdr_data_Re(const Vector &x, Vector &E)
|
||||
}
|
||||
if (!in_pml)
|
||||
{
|
||||
vector<complex<double>> Eval(E.Size());
|
||||
vector<complex<real_t>> Eval(E.Size());
|
||||
maxwell_solution(x, Eval);
|
||||
for (int i = 0; i < dim; ++i)
|
||||
{
|
||||
@@ -896,7 +896,7 @@ void E_bdr_data_Im(const Vector &x, Vector &E)
|
||||
}
|
||||
if (!in_pml)
|
||||
{
|
||||
vector<complex<double>> Eval(E.Size());
|
||||
vector<complex<real_t>> Eval(E.Size());
|
||||
maxwell_solution(x, Eval);
|
||||
for (int i = 0; i < dim; ++i)
|
||||
{
|
||||
@@ -907,8 +907,8 @@ void E_bdr_data_Im(const Vector &x, Vector &E)
|
||||
|
||||
void detJ_JT_J_inv_Re(const Vector &x, PML * pml, Vector & D)
|
||||
{
|
||||
vector<complex<double>> dxs(dim);
|
||||
complex<double> det(1.0, 0.0);
|
||||
vector<complex<real_t>> dxs(dim);
|
||||
complex<real_t> det(1.0, 0.0);
|
||||
pml->StretchFunction(x, dxs);
|
||||
|
||||
for (int i = 0; i < dim; ++i)
|
||||
@@ -918,14 +918,14 @@ void detJ_JT_J_inv_Re(const Vector &x, PML * pml, Vector & D)
|
||||
|
||||
for (int i = 0; i < dim; ++i)
|
||||
{
|
||||
D(i) = (det / pow(dxs[i], 2)).real();
|
||||
D(i) = (det / pow(dxs[i], real_t(2))).real();
|
||||
}
|
||||
}
|
||||
|
||||
void detJ_JT_J_inv_Im(const Vector &x, PML * pml, Vector & D)
|
||||
{
|
||||
vector<complex<double>> dxs(dim);
|
||||
complex<double> det = 1.0;
|
||||
vector<complex<real_t>> dxs(dim);
|
||||
complex<real_t> det = 1.0;
|
||||
pml->StretchFunction(x, dxs);
|
||||
|
||||
for (int i = 0; i < dim; ++i)
|
||||
@@ -935,14 +935,14 @@ void detJ_JT_J_inv_Im(const Vector &x, PML * pml, Vector & D)
|
||||
|
||||
for (int i = 0; i < dim; ++i)
|
||||
{
|
||||
D(i) = (det / pow(dxs[i], 2)).imag();
|
||||
D(i) = (det / pow(dxs[i], real_t(2))).imag();
|
||||
}
|
||||
}
|
||||
|
||||
void detJ_JT_J_inv_abs(const Vector &x, PML * pml, Vector & D)
|
||||
{
|
||||
vector<complex<double>> dxs(dim);
|
||||
complex<double> det = 1.0;
|
||||
vector<complex<real_t>> dxs(dim);
|
||||
complex<real_t> det = 1.0;
|
||||
pml->StretchFunction(x, dxs);
|
||||
|
||||
for (int i = 0; i < dim; ++i)
|
||||
@@ -952,14 +952,14 @@ void detJ_JT_J_inv_abs(const Vector &x, PML * pml, Vector & D)
|
||||
|
||||
for (int i = 0; i < dim; ++i)
|
||||
{
|
||||
D(i) = abs(det / pow(dxs[i], 2));
|
||||
D(i) = abs(det / pow(dxs[i], real_t(2)));
|
||||
}
|
||||
}
|
||||
|
||||
void detJ_inv_JT_J_Re(const Vector &x, PML * pml, Vector & D)
|
||||
{
|
||||
vector<complex<double>> dxs(dim);
|
||||
complex<double> det(1.0, 0.0);
|
||||
vector<complex<real_t>> dxs(dim);
|
||||
complex<real_t> det(1.0, 0.0);
|
||||
pml->StretchFunction(x, dxs);
|
||||
|
||||
for (int i = 0; i < dim; ++i)
|
||||
@@ -970,21 +970,21 @@ void detJ_inv_JT_J_Re(const Vector &x, PML * pml, Vector & D)
|
||||
// in the 2D case the coefficient is scalar 1/det(J)
|
||||
if (dim == 2)
|
||||
{
|
||||
D = (1.0 / det).real();
|
||||
D = (real_t(1) / det).real();
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < dim; ++i)
|
||||
{
|
||||
D(i) = (pow(dxs[i], 2) / det).real();
|
||||
D(i) = (pow(dxs[i], real_t(2)) / det).real();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void detJ_inv_JT_J_Im(const Vector &x, PML * pml, Vector & D)
|
||||
{
|
||||
vector<complex<double>> dxs(dim);
|
||||
complex<double> det = 1.0;
|
||||
vector<complex<real_t>> dxs(dim);
|
||||
complex<real_t> det = 1.0;
|
||||
pml->StretchFunction(x, dxs);
|
||||
|
||||
for (int i = 0; i < dim; ++i)
|
||||
@@ -994,21 +994,21 @@ void detJ_inv_JT_J_Im(const Vector &x, PML * pml, Vector & D)
|
||||
|
||||
if (dim == 2)
|
||||
{
|
||||
D = (1.0 / det).imag();
|
||||
D = (real_t(1) / det).imag();
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < dim; ++i)
|
||||
{
|
||||
D(i) = (pow(dxs[i], 2) / det).imag();
|
||||
D(i) = (pow(dxs[i], real_t(2)) / det).imag();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void detJ_inv_JT_J_abs(const Vector &x, PML * pml, Vector & D)
|
||||
{
|
||||
vector<complex<double>> dxs(dim);
|
||||
complex<double> det = 1.0;
|
||||
vector<complex<real_t>> dxs(dim);
|
||||
complex<real_t> det = 1.0;
|
||||
pml->StretchFunction(x, dxs);
|
||||
|
||||
for (int i = 0; i < dim; ++i)
|
||||
@@ -1018,18 +1018,18 @@ void detJ_inv_JT_J_abs(const Vector &x, PML * pml, Vector & D)
|
||||
|
||||
if (dim == 2)
|
||||
{
|
||||
D = abs(1.0 / det);
|
||||
D = abs(real_t(1) / det);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < dim; ++i)
|
||||
{
|
||||
D(i) = abs(pow(dxs[i], 2) / det);
|
||||
D(i) = abs(pow(dxs[i], real_t(2)) / det);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PML::PML(Mesh *mesh_, Array2D<double> length_)
|
||||
PML::PML(Mesh *mesh_, Array2D<real_t> length_)
|
||||
: mesh(mesh_), length(length_)
|
||||
{
|
||||
dim = mesh->Dimension();
|
||||
@@ -1081,7 +1081,7 @@ void PML::SetAttributes(ParMesh *pmesh)
|
||||
for (int iv = 0; iv < nrvert; ++iv)
|
||||
{
|
||||
int vert_idx = vertices[iv];
|
||||
double *coords = pmesh->GetVertex(vert_idx);
|
||||
real_t *coords = pmesh->GetVertex(vert_idx);
|
||||
for (int comp = 0; comp < dim; ++comp)
|
||||
{
|
||||
if (coords[comp] > comp_dom_bdr(comp, 1) ||
|
||||
@@ -1102,14 +1102,14 @@ void PML::SetAttributes(ParMesh *pmesh)
|
||||
}
|
||||
|
||||
void PML::StretchFunction(const Vector &x,
|
||||
vector<complex<double>> &dxs)
|
||||
vector<complex<real_t>> &dxs)
|
||||
{
|
||||
complex<double> zi = complex<double>(0., 1.);
|
||||
complex<real_t> zi = complex<real_t>(0., 1.);
|
||||
|
||||
double n = 2.0;
|
||||
double c = 5.0;
|
||||
double coeff;
|
||||
double k = omega * sqrt(epsilon * mu);
|
||||
real_t n = 2.0;
|
||||
real_t c = 5.0;
|
||||
real_t coeff;
|
||||
real_t k = omega * sqrt(epsilon * mu);
|
||||
|
||||
// Stretch in each direction independently
|
||||
for (int i = 0; i < dim; ++i)
|
||||
@@ -1118,14 +1118,14 @@ void PML::StretchFunction(const Vector &x,
|
||||
if (x(i) >= comp_domain_bdr(i, 1))
|
||||
{
|
||||
coeff = n * c / k / pow(length(i, 1), n);
|
||||
dxs[i] = 1.0 + zi * coeff *
|
||||
abs(pow(x(i) - comp_domain_bdr(i, 1), n - 1.0));
|
||||
dxs[i] = real_t(1) + zi * coeff *
|
||||
abs(pow(x(i) - comp_domain_bdr(i, 1), n - real_t(1)));
|
||||
}
|
||||
if (x(i) <= comp_domain_bdr(i, 0))
|
||||
{
|
||||
coeff = n * c / k / pow(length(i, 0), n);
|
||||
dxs[i] = 1.0 + zi * coeff *
|
||||
abs(pow(x(i) - comp_domain_bdr(i, 0), n - 1.0));
|
||||
dxs[i] = real_t(1) + zi * coeff *
|
||||
abs(pow(x(i) - comp_domain_bdr(i, 0), n - real_t(1)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+32
-32
@@ -63,7 +63,7 @@
|
||||
using namespace std;
|
||||
using namespace mfem;
|
||||
|
||||
static double a_ = 0.2;
|
||||
static real_t a_ = 0.2;
|
||||
|
||||
// Normal to hole with boundary attribute 4
|
||||
void n4Vec(const Vector &x, Vector &n) { n = x; n[0] -= 0.5; n /= -n.Norml2(); }
|
||||
@@ -73,25 +73,25 @@ Mesh * GenerateSerialMesh(int ref);
|
||||
// Compute the average value of alpha*n.Grad(sol) + beta*sol over the boundary
|
||||
// attributes marked in bdr_marker. Also computes the L2 norm of
|
||||
// alpha*n.Grad(sol) + beta*sol - gamma over the same boundary.
|
||||
double IntegrateBC(const GridFunction &sol, const Array<int> &bdr_marker,
|
||||
double alpha, double beta, double gamma,
|
||||
double &error);
|
||||
real_t IntegrateBC(const GridFunction &sol, const Array<int> &bdr_marker,
|
||||
real_t alpha, real_t beta, real_t gamma,
|
||||
real_t &error);
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
// 1. Parse command-line options.
|
||||
int ser_ref_levels = 2;
|
||||
int order = 1;
|
||||
double sigma = -1.0;
|
||||
double kappa = -1.0;
|
||||
real_t sigma = -1.0;
|
||||
real_t kappa = -1.0;
|
||||
bool h1 = true;
|
||||
bool visualization = true;
|
||||
|
||||
double mat_val = 1.0;
|
||||
double dbc_val = 0.0;
|
||||
double nbc_val = 1.0;
|
||||
double rbc_a_val = 1.0; // du/dn + a * u = b
|
||||
double rbc_b_val = 1.0;
|
||||
real_t mat_val = 1.0;
|
||||
real_t dbc_val = 0.0;
|
||||
real_t nbc_val = 1.0;
|
||||
real_t rbc_a_val = 1.0; // du/dn + a * u = b
|
||||
real_t rbc_b_val = 1.0;
|
||||
|
||||
OptionsParser args(argc, argv);
|
||||
args.AddOption(&h1, "-h1", "--continuous", "-dg", "--discontinuous",
|
||||
@@ -302,7 +302,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
// Integrate the solution on the Dirichlet boundary and compare to the
|
||||
// expected value.
|
||||
double error, avg = IntegrateBC(u, dbc_bdr, 0.0, 1.0, dbc_val, error);
|
||||
real_t error, avg = IntegrateBC(u, dbc_bdr, 0.0, 1.0, dbc_val, error);
|
||||
|
||||
bool hom_dbc = (dbc_val == 0.0);
|
||||
error /= hom_dbc ? 1.0 : fabs(dbc_val);
|
||||
@@ -314,7 +314,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
// Integrate n.Grad(u) on the inhomogeneous Neumann boundary and compare
|
||||
// to the expected value.
|
||||
double error, avg = IntegrateBC(u, nbc_bdr, 1.0, 0.0, nbc_val, error);
|
||||
real_t error, avg = IntegrateBC(u, nbc_bdr, 1.0, 0.0, nbc_val, error);
|
||||
|
||||
bool hom_nbc = (nbc_val == 0.0);
|
||||
error /= hom_nbc ? 1.0 : fabs(nbc_val);
|
||||
@@ -330,7 +330,7 @@ int main(int argc, char *argv[])
|
||||
nbc0_bdr = 0;
|
||||
nbc0_bdr[3] = 1;
|
||||
|
||||
double error, avg = IntegrateBC(u, nbc0_bdr, 1.0, 0.0, 0.0, error);
|
||||
real_t error, avg = IntegrateBC(u, nbc0_bdr, 1.0, 0.0, 0.0, error);
|
||||
|
||||
bool hom_nbc = true;
|
||||
mfem::out << "Average of n.Grad(u) on Gamma_nbc0:\t"
|
||||
@@ -341,8 +341,8 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
// Integrate n.Grad(u) + a * u on the Robin boundary and compare to the
|
||||
// expected value.
|
||||
double error;
|
||||
double avg = IntegrateBC(u, rbc_bdr, 1.0, rbc_a_val, rbc_b_val, error);
|
||||
real_t error;
|
||||
real_t avg = IntegrateBC(u, rbc_bdr, 1.0, rbc_a_val, rbc_b_val, error);
|
||||
|
||||
bool hom_rbc = (rbc_b_val == 0.0);
|
||||
error /= hom_rbc ? 1.0 : fabs(rbc_b_val);
|
||||
@@ -383,22 +383,22 @@ int main(int argc, char *argv[])
|
||||
return 0;
|
||||
}
|
||||
|
||||
void quad_trans(double u, double v, double &x, double &y, bool log = false)
|
||||
void quad_trans(real_t u, real_t v, real_t &x, real_t &y, bool log = false)
|
||||
{
|
||||
double a = a_; // Radius of disc
|
||||
real_t a = a_; // Radius of disc
|
||||
|
||||
double d = 4.0 * a * (M_SQRT2 - 2.0 * a) * (1.0 - 2.0 * v);
|
||||
real_t d = 4.0 * a * (M_SQRT2 - 2.0 * a) * (1.0 - 2.0 * v);
|
||||
|
||||
double v0 = (1.0 + M_SQRT2) * (M_SQRT2 * a - 2.0 * v) *
|
||||
real_t v0 = (1.0 + M_SQRT2) * (M_SQRT2 * a - 2.0 * v) *
|
||||
((4.0 - 3 * M_SQRT2) * a +
|
||||
(8.0 * (M_SQRT2 - 1.0) * a - 2.0) * v) / d;
|
||||
|
||||
double r = 2.0 * ((M_SQRT2 - 1.0) * a * a * (1.0 - 4.0 *v) +
|
||||
real_t r = 2.0 * ((M_SQRT2 - 1.0) * a * a * (1.0 - 4.0 *v) +
|
||||
2.0 * (1.0 + M_SQRT2 *
|
||||
(1.0 + 2.0 * (2.0 * a - M_SQRT2 - 1.0) * a)) * v * v
|
||||
) / d;
|
||||
|
||||
double t = asin(v / r) * u / v;
|
||||
real_t t = asin(v / r) * u / v;
|
||||
if (log)
|
||||
{
|
||||
mfem::out << "u, v, r, v0, t "
|
||||
@@ -411,7 +411,7 @@ void quad_trans(double u, double v, double &x, double &y, bool log = false)
|
||||
|
||||
void trans(const Vector &u, Vector &x)
|
||||
{
|
||||
double tol = 1e-4;
|
||||
real_t tol = 1e-4;
|
||||
|
||||
if (u[1] > 0.5 - tol || u[1] < -0.5 + tol)
|
||||
{
|
||||
@@ -542,8 +542,8 @@ Mesh * GenerateSerialMesh(int ref)
|
||||
vi[0] = o + 3; vi[1] = o + 4; mesh->AddBdrSegment(vi, 3 + i);
|
||||
}
|
||||
|
||||
double d[2];
|
||||
double a = a_ / M_SQRT2;
|
||||
real_t d[2];
|
||||
real_t a = a_ / M_SQRT2;
|
||||
|
||||
d[0] = -1.0; d[1] = -0.5; mesh->AddVertex(d);
|
||||
d[0] = -1.0; d[1] = 0.0; mesh->AddVertex(d);
|
||||
@@ -636,12 +636,12 @@ Mesh * GenerateSerialMesh(int ref)
|
||||
return mesh;
|
||||
}
|
||||
|
||||
double IntegrateBC(const GridFunction &x, const Array<int> &bdr,
|
||||
double alpha, double beta, double gamma,
|
||||
double &error)
|
||||
real_t IntegrateBC(const GridFunction &x, const Array<int> &bdr,
|
||||
real_t alpha, real_t beta, real_t gamma,
|
||||
real_t &error)
|
||||
{
|
||||
double nrm = 0.0;
|
||||
double avg = 0.0;
|
||||
real_t nrm = 0.0;
|
||||
real_t avg = 0.0;
|
||||
error = 0.0;
|
||||
|
||||
const bool a_is_zero = alpha == 0.0;
|
||||
@@ -683,8 +683,8 @@ double IntegrateBC(const GridFunction &x, const Array<int> &bdr,
|
||||
IntegrationPoint eip;
|
||||
FTr->Loc1.Transform(ip, eip);
|
||||
FTr->Face->SetIntPoint(&ip);
|
||||
double face_weight = FTr->Face->Weight();
|
||||
double val = 0.0;
|
||||
real_t face_weight = FTr->Face->Weight();
|
||||
real_t val = 0.0;
|
||||
if (!a_is_zero)
|
||||
{
|
||||
FTr->Elem1->SetIntPoint(&eip);
|
||||
|
||||
+38
-37
@@ -63,7 +63,7 @@
|
||||
using namespace std;
|
||||
using namespace mfem;
|
||||
|
||||
static double a_ = 0.2;
|
||||
static real_t a_ = 0.2;
|
||||
|
||||
// Normal to hole with boundary attribute 4
|
||||
void n4Vec(const Vector &x, Vector &n) { n = x; n[0] -= 0.5; n /= -n.Norml2(); }
|
||||
@@ -73,9 +73,9 @@ Mesh * GenerateSerialMesh(int ref);
|
||||
// Compute the average value of alpha*n.Grad(sol) + beta*sol over the boundary
|
||||
// attributes marked in bdr_marker. Also computes the L2 norm of
|
||||
// alpha*n.Grad(sol) + beta*sol - gamma over the same boundary.
|
||||
double IntegrateBC(const ParGridFunction &sol, const Array<int> &bdr_marker,
|
||||
double alpha, double beta, double gamma,
|
||||
double &error);
|
||||
real_t IntegrateBC(const ParGridFunction &sol, const Array<int> &bdr_marker,
|
||||
real_t alpha, real_t beta, real_t gamma,
|
||||
real_t &error);
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
@@ -88,16 +88,16 @@ int main(int argc, char *argv[])
|
||||
int ser_ref_levels = 2;
|
||||
int par_ref_levels = 1;
|
||||
int order = 1;
|
||||
double sigma = -1.0;
|
||||
double kappa = -1.0;
|
||||
real_t sigma = -1.0;
|
||||
real_t kappa = -1.0;
|
||||
bool h1 = true;
|
||||
bool visualization = true;
|
||||
|
||||
double mat_val = 1.0;
|
||||
double dbc_val = 0.0;
|
||||
double nbc_val = 1.0;
|
||||
double rbc_a_val = 1.0; // du/dn + a * u = b
|
||||
double rbc_b_val = 1.0;
|
||||
real_t mat_val = 1.0;
|
||||
real_t dbc_val = 0.0;
|
||||
real_t nbc_val = 1.0;
|
||||
real_t rbc_a_val = 1.0; // du/dn + a * u = b
|
||||
real_t rbc_b_val = 1.0;
|
||||
|
||||
OptionsParser args(argc, argv);
|
||||
args.AddOption(&h1, "-h1", "--continuous", "-dg", "--discontinuous",
|
||||
@@ -322,7 +322,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
// Integrate the solution on the Dirichlet boundary and compare to the
|
||||
// expected value.
|
||||
double error, avg = IntegrateBC(u, dbc_bdr, 0.0, 1.0, dbc_val, error);
|
||||
real_t error, avg = IntegrateBC(u, dbc_bdr, 0.0, 1.0, dbc_val, error);
|
||||
|
||||
bool hom_dbc = (dbc_val == 0.0);
|
||||
error /= hom_dbc ? 1.0 : fabs(dbc_val);
|
||||
@@ -334,7 +334,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
// Integrate n.Grad(u) on the inhomogeneous Neumann boundary and compare
|
||||
// to the expected value.
|
||||
double error, avg = IntegrateBC(u, nbc_bdr, 1.0, 0.0, nbc_val, error);
|
||||
real_t error, avg = IntegrateBC(u, nbc_bdr, 1.0, 0.0, nbc_val, error);
|
||||
|
||||
bool hom_nbc = (nbc_val == 0.0);
|
||||
error /= hom_nbc ? 1.0 : fabs(nbc_val);
|
||||
@@ -350,7 +350,7 @@ int main(int argc, char *argv[])
|
||||
nbc0_bdr = 0;
|
||||
nbc0_bdr[3] = 1;
|
||||
|
||||
double error, avg = IntegrateBC(u, nbc0_bdr, 1.0, 0.0, 0.0, error);
|
||||
real_t error, avg = IntegrateBC(u, nbc0_bdr, 1.0, 0.0, 0.0, error);
|
||||
|
||||
bool hom_nbc = true;
|
||||
mfem::out << "Average of n.Grad(u) on Gamma_nbc0:\t"
|
||||
@@ -361,7 +361,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
// Integrate n.Grad(u) + a * u on the Robin boundary and compare to the
|
||||
// expected value.
|
||||
double error, avg = IntegrateBC(u, rbc_bdr, 1.0, rbc_a_val, rbc_b_val,
|
||||
real_t error, avg = IntegrateBC(u, rbc_bdr, 1.0, rbc_a_val, rbc_b_val,
|
||||
error);
|
||||
|
||||
bool hom_rbc = (rbc_b_val == 0.0);
|
||||
@@ -409,22 +409,22 @@ int main(int argc, char *argv[])
|
||||
return 0;
|
||||
}
|
||||
|
||||
void quad_trans(double u, double v, double &x, double &y, bool log = false)
|
||||
void quad_trans(real_t u, real_t v, real_t &x, real_t &y, bool log = false)
|
||||
{
|
||||
double a = a_; // Radius of disc
|
||||
real_t a = a_; // Radius of disc
|
||||
|
||||
double d = 4.0 * a * (M_SQRT2 - 2.0 * a) * (1.0 - 2.0 * v);
|
||||
real_t d = 4.0 * a * (M_SQRT2 - 2.0 * a) * (1.0 - 2.0 * v);
|
||||
|
||||
double v0 = (1.0 + M_SQRT2) * (M_SQRT2 * a - 2.0 * v) *
|
||||
real_t v0 = (1.0 + M_SQRT2) * (M_SQRT2 * a - 2.0 * v) *
|
||||
((4.0 - 3 * M_SQRT2) * a +
|
||||
(8.0 * (M_SQRT2 - 1.0) * a - 2.0) * v) / d;
|
||||
|
||||
double r = 2.0 * ((M_SQRT2 - 1.0) * a * a * (1.0 - 4.0 *v) +
|
||||
real_t r = 2.0 * ((M_SQRT2 - 1.0) * a * a * (1.0 - 4.0 *v) +
|
||||
2.0 * (1.0 + M_SQRT2 *
|
||||
(1.0 + 2.0 * (2.0 * a - M_SQRT2 - 1.0) * a)) * v * v
|
||||
) / d;
|
||||
|
||||
double t = asin(v / r) * u / v;
|
||||
real_t t = asin(v / r) * u / v;
|
||||
if (log)
|
||||
{
|
||||
mfem::out << "u, v, r, v0, t "
|
||||
@@ -437,7 +437,7 @@ void quad_trans(double u, double v, double &x, double &y, bool log = false)
|
||||
|
||||
void trans(const Vector &u, Vector &x)
|
||||
{
|
||||
double tol = 1e-4;
|
||||
real_t tol = 1e-4;
|
||||
|
||||
if (u[1] > 0.5 - tol || u[1] < -0.5 + tol)
|
||||
{
|
||||
@@ -568,8 +568,8 @@ Mesh * GenerateSerialMesh(int ref)
|
||||
vi[0] = o + 3; vi[1] = o + 4; mesh->AddBdrSegment(vi, 3 + i);
|
||||
}
|
||||
|
||||
double d[2];
|
||||
double a = a_ / M_SQRT2;
|
||||
real_t d[2];
|
||||
real_t a = a_ / M_SQRT2;
|
||||
|
||||
d[0] = -1.0; d[1] = -0.5; mesh->AddVertex(d);
|
||||
d[0] = -1.0; d[1] = 0.0; mesh->AddVertex(d);
|
||||
@@ -662,14 +662,14 @@ Mesh * GenerateSerialMesh(int ref)
|
||||
return mesh;
|
||||
}
|
||||
|
||||
double IntegrateBC(const ParGridFunction &x, const Array<int> &bdr,
|
||||
double alpha, double beta, double gamma,
|
||||
double &glb_err)
|
||||
real_t IntegrateBC(const ParGridFunction &x, const Array<int> &bdr,
|
||||
real_t alpha, real_t beta, real_t gamma,
|
||||
real_t &glb_err)
|
||||
{
|
||||
double loc_vals[3];
|
||||
double &nrm = loc_vals[0];
|
||||
double &avg = loc_vals[1];
|
||||
double &error = loc_vals[2];
|
||||
real_t loc_vals[3];
|
||||
real_t &nrm = loc_vals[0];
|
||||
real_t &avg = loc_vals[1];
|
||||
real_t &error = loc_vals[2];
|
||||
|
||||
nrm = 0.0;
|
||||
avg = 0.0;
|
||||
@@ -714,8 +714,8 @@ double IntegrateBC(const ParGridFunction &x, const Array<int> &bdr,
|
||||
IntegrationPoint eip;
|
||||
FTr->Loc1.Transform(ip, eip);
|
||||
FTr->Face->SetIntPoint(&ip);
|
||||
double face_weight = FTr->Face->Weight();
|
||||
double val = 0.0;
|
||||
real_t face_weight = FTr->Face->Weight();
|
||||
real_t val = 0.0;
|
||||
if (!a_is_zero)
|
||||
{
|
||||
FTr->Elem1->SetIntPoint(&eip);
|
||||
@@ -741,11 +741,12 @@ double IntegrateBC(const ParGridFunction &x, const Array<int> &bdr,
|
||||
}
|
||||
}
|
||||
|
||||
double glb_vals[3];
|
||||
MPI_Allreduce(loc_vals, glb_vals, 3, MPI_DOUBLE, MPI_SUM, fes.GetComm());
|
||||
real_t glb_vals[3];
|
||||
MPI_Allreduce(loc_vals, glb_vals, 3, MPITypeMap<real_t>::mpi_type,
|
||||
MPI_SUM, fes.GetComm());
|
||||
|
||||
double glb_nrm = glb_vals[0];
|
||||
double glb_avg = glb_vals[1];
|
||||
real_t glb_nrm = glb_vals[0];
|
||||
real_t glb_avg = glb_vals[1];
|
||||
glb_err = glb_vals[2];
|
||||
|
||||
// Normalize by the length of the boundary
|
||||
|
||||
+3
-3
@@ -35,7 +35,7 @@ using namespace mfem;
|
||||
// Return a mesh with a single element with vertices (0, 0), (1, 0), (1, 1),
|
||||
// (offset, 1) to demonstrate boundary conditions on a surface that is not
|
||||
// axis-aligned.
|
||||
Mesh * build_trapezoid_mesh(double offset)
|
||||
Mesh * build_trapezoid_mesh(real_t offset)
|
||||
{
|
||||
MFEM_VERIFY(offset < 0.9, "offset is too large!");
|
||||
|
||||
@@ -45,7 +45,7 @@ Mesh * build_trapezoid_mesh(double offset)
|
||||
Mesh * mesh = new Mesh(dimension, nvt, 1, nbe);
|
||||
|
||||
// vertices
|
||||
double vc[dimension];
|
||||
real_t vc[dimension];
|
||||
vc[0] = 0.0; vc[1] = 0.0;
|
||||
mesh->AddVertex(vc);
|
||||
vc[0] = 1.0; vc[1] = 0.0;
|
||||
@@ -81,7 +81,7 @@ int main(int argc, char *argv[])
|
||||
// 1. Parse command-line options.
|
||||
int order = 1;
|
||||
bool visualization = 1;
|
||||
double offset = 0.3;
|
||||
real_t offset = 0.3;
|
||||
bool visit = false;
|
||||
|
||||
OptionsParser args(argc, argv);
|
||||
|
||||
+4
-4
@@ -38,7 +38,7 @@ using namespace mfem;
|
||||
// Return a mesh with a single element with vertices (0, 0), (1, 0), (1, 1),
|
||||
// (offset, 1) to demonstrate boundary conditions on a surface that is not
|
||||
// axis-aligned.
|
||||
Mesh * build_trapezoid_mesh(double offset)
|
||||
Mesh * build_trapezoid_mesh(real_t offset)
|
||||
{
|
||||
MFEM_VERIFY(offset < 0.9, "offset is too large!");
|
||||
|
||||
@@ -48,7 +48,7 @@ Mesh * build_trapezoid_mesh(double offset)
|
||||
Mesh * mesh = new Mesh(dimension, nvt, 1, nbe);
|
||||
|
||||
// vertices
|
||||
double vc[dimension];
|
||||
real_t vc[dimension];
|
||||
vc[0] = 0.0; vc[1] = 0.0;
|
||||
mesh->AddVertex(vc);
|
||||
vc[0] = 1.0; vc[1] = 0.0;
|
||||
@@ -97,9 +97,9 @@ int main(int argc, char *argv[])
|
||||
int order = 1;
|
||||
bool visualization = 1;
|
||||
bool reorder_space = false;
|
||||
double offset = 0.3;
|
||||
real_t offset = 0.3;
|
||||
bool visit = false;
|
||||
double penalty = 0.0;
|
||||
real_t penalty = 0.0;
|
||||
|
||||
OptionsParser args(argc, argv);
|
||||
args.AddOption(&order, "-o", "--order",
|
||||
|
||||
+6
-6
@@ -34,7 +34,7 @@ void trans(const Vector &x, Vector &r);
|
||||
|
||||
void sigmaFunc(const Vector &x, DenseMatrix &s);
|
||||
|
||||
double uExact(const Vector &x)
|
||||
real_t uExact(const Vector &x)
|
||||
{
|
||||
return (0.25 * (2.0 + x[0]) - x[2]) * (x[2] + 0.25 * (2.0 + x[0]));
|
||||
}
|
||||
@@ -167,7 +167,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
// 13. Compute error in the solution and its flux
|
||||
FunctionCoefficient uCoef(uExact);
|
||||
double error = x.ComputeL2Error(uCoef);
|
||||
real_t error = x.ComputeL2Error(uCoef);
|
||||
|
||||
cout << "|u - u_h|_2 = " << error << endl;
|
||||
|
||||
@@ -176,7 +176,7 @@ int main(int argc, char *argv[])
|
||||
x.ComputeFlux(*integ, flux); flux *= -1.0;
|
||||
|
||||
VectorFunctionCoefficient fluxCoef(3, fluxExact);
|
||||
double flux_err = flux.ComputeL2Error(fluxCoef);
|
||||
real_t flux_err = flux.ComputeL2Error(fluxCoef);
|
||||
|
||||
cout << "|f - f_h|_2 = " << flux_err << endl;
|
||||
|
||||
@@ -304,8 +304,8 @@ void trans(const Vector &x, Vector &r)
|
||||
{
|
||||
r.SetSize(3);
|
||||
|
||||
double tol = 1e-6;
|
||||
double theta = 0.0;
|
||||
real_t tol = 1e-6;
|
||||
real_t theta = 0.0;
|
||||
if (fabs(x[1] + 1.0) < tol)
|
||||
{
|
||||
theta = 0.25 * M_PI * (x[0] - 2.0);
|
||||
@@ -337,7 +337,7 @@ void trans(const Vector &x, Vector &r)
|
||||
void sigmaFunc(const Vector &x, DenseMatrix &s)
|
||||
{
|
||||
s.SetSize(3);
|
||||
double a = 17.0 - 2.0 * x[0] * (1.0 + x[0]);
|
||||
real_t a = 17.0 - 2.0 * x[0] * (1.0 + x[0]);
|
||||
s(0,0) = 0.5 + x[0] * x[0] * (8.0 / a - 0.5);
|
||||
s(0,1) = x[0] * x[1] * (8.0 / a - 0.5);
|
||||
s(0,2) = 0.0;
|
||||
|
||||
+6
-6
@@ -34,7 +34,7 @@ void trans(const Vector &x, Vector &r);
|
||||
|
||||
void sigmaFunc(const Vector &x, DenseMatrix &s);
|
||||
|
||||
double uExact(const Vector &x)
|
||||
real_t uExact(const Vector &x)
|
||||
{
|
||||
return (0.25 * (2.0 + x[0]) - x[2]) * (x[2] + 0.25 * (2.0 + x[0]));
|
||||
}
|
||||
@@ -201,7 +201,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
// 15. Compute error in the solution and its flux
|
||||
FunctionCoefficient uCoef(uExact);
|
||||
double error = x.ComputeL2Error(uCoef);
|
||||
real_t error = x.ComputeL2Error(uCoef);
|
||||
|
||||
if (myid == 0) { cout << "|u - u_h|_2 = " << error << endl; }
|
||||
|
||||
@@ -210,7 +210,7 @@ int main(int argc, char *argv[])
|
||||
x.ComputeFlux(*integ, flux); flux *= -1.0;
|
||||
|
||||
VectorFunctionCoefficient fluxCoef(3, fluxExact);
|
||||
double flux_err = flux.ComputeL2Error(fluxCoef);
|
||||
real_t flux_err = flux.ComputeL2Error(fluxCoef);
|
||||
|
||||
if (myid == 0) { cout << "|f - f_h|_2 = " << flux_err << endl; }
|
||||
|
||||
@@ -349,8 +349,8 @@ void trans(const Vector &x, Vector &r)
|
||||
{
|
||||
r.SetSize(3);
|
||||
|
||||
double tol = 1e-6;
|
||||
double theta = 0.0;
|
||||
real_t tol = 1e-6;
|
||||
real_t theta = 0.0;
|
||||
if (fabs(x[1] + 1.0) < tol)
|
||||
{
|
||||
theta = 0.25 * M_PI * (x[0] - 2.0);
|
||||
@@ -382,7 +382,7 @@ void trans(const Vector &x, Vector &r)
|
||||
void sigmaFunc(const Vector &x, DenseMatrix &s)
|
||||
{
|
||||
s.SetSize(3);
|
||||
double a = 17.0 - 2.0 * x[0] * (1.0 + x[0]);
|
||||
real_t a = 17.0 - 2.0 * x[0] * (1.0 + x[0]);
|
||||
s(0,0) = 0.5 + x[0] * x[0] * (8.0 / a - 0.5);
|
||||
s(0,1) = x[0] * x[1] * (8.0 / a - 0.5);
|
||||
s(0,2) = 0.0;
|
||||
|
||||
+1
-1
@@ -53,7 +53,7 @@ using namespace mfem;
|
||||
// Exact solution, E, and r.h.s., f. See below for implementation.
|
||||
void E_exact(const Vector &, Vector &);
|
||||
void f_exact(const Vector &, Vector &);
|
||||
double freq = 1.0, kappa;
|
||||
real_t freq = 1.0, kappa;
|
||||
int dim;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
|
||||
+14
-14
@@ -42,9 +42,9 @@ using namespace std;
|
||||
using namespace mfem;
|
||||
|
||||
// Piecewise-affine function which is sometimes mesh-conforming
|
||||
double affine_function(const Vector &p)
|
||||
real_t affine_function(const Vector &p)
|
||||
{
|
||||
double x = p(0), y = p(1);
|
||||
real_t x = p(0), y = p(1);
|
||||
if (x < 0.0)
|
||||
{
|
||||
return 1.0 + x + y;
|
||||
@@ -56,7 +56,7 @@ double affine_function(const Vector &p)
|
||||
}
|
||||
|
||||
// Piecewise-constant function which is never mesh-conforming
|
||||
double jump_function(const Vector &p)
|
||||
real_t jump_function(const Vector &p)
|
||||
{
|
||||
if (p.Normlp(2.0) > 0.4 && p.Normlp(2.0) < 0.6)
|
||||
{
|
||||
@@ -70,17 +70,17 @@ double jump_function(const Vector &p)
|
||||
|
||||
// Singular function derived from the Laplacian of the "steep wavefront" problem
|
||||
// in [2].
|
||||
double singular_function(const Vector &p)
|
||||
real_t singular_function(const Vector &p)
|
||||
{
|
||||
double x = p(0), y = p(1);
|
||||
double alpha = 1000.0;
|
||||
double xc = 0.75, yc = 0.5;
|
||||
double r0 = 0.7;
|
||||
double r = sqrt(pow(x - xc,2.0) + pow(y - yc,2.0));
|
||||
double num = - ( alpha - pow(alpha,3) * (pow(r,2) - pow(r0,2)) );
|
||||
double denom = pow(r * ( pow(alpha,2) * pow(r0,2) + pow(alpha,2) * pow(r,2) \
|
||||
real_t x = p(0), y = p(1);
|
||||
real_t alpha = 1000.0;
|
||||
real_t xc = 0.75, yc = 0.5;
|
||||
real_t r0 = 0.7;
|
||||
real_t r = sqrt(pow(x - xc,2.0) + pow(y - yc,2.0));
|
||||
real_t num = - ( alpha - pow(alpha,3) * (pow(r,2) - pow(r0,2)) );
|
||||
real_t denom = pow(r * ( pow(alpha,2) * pow(r0,2) + pow(alpha,2) * pow(r,2) \
|
||||
- 2 * pow(alpha,2) * r0 * r + 1.0 ),2);
|
||||
denom = max(denom,1e-8);
|
||||
denom = std::max(denom, (real_t) 1.0e-8);
|
||||
return num / denom;
|
||||
}
|
||||
|
||||
@@ -91,9 +91,9 @@ int main(int argc, char *argv[])
|
||||
int order = 1;
|
||||
int nc_limit = 1;
|
||||
int max_elems = 100*1000;
|
||||
double double_max_elems = double(max_elems);
|
||||
real_t double_max_elems = real_t(max_elems);
|
||||
bool visualization = true;
|
||||
double osc_threshold = 1e-3;
|
||||
real_t osc_threshold = 1e-3;
|
||||
int enriched_order = 5;
|
||||
|
||||
OptionsParser args(argc, argv);
|
||||
|
||||
+15
-15
@@ -42,9 +42,9 @@ using namespace std;
|
||||
using namespace mfem;
|
||||
|
||||
// Piecewise-affine function which is sometimes mesh-conforming
|
||||
double affine_function(const Vector &p)
|
||||
real_t affine_function(const Vector &p)
|
||||
{
|
||||
double x = p(0), y = p(1);
|
||||
real_t x = p(0), y = p(1);
|
||||
if (x < 0.0)
|
||||
{
|
||||
return 1.0 + x + y;
|
||||
@@ -56,7 +56,7 @@ double affine_function(const Vector &p)
|
||||
}
|
||||
|
||||
// Piecewise-constant function which is never mesh-conforming
|
||||
double jump_function(const Vector &p)
|
||||
real_t jump_function(const Vector &p)
|
||||
{
|
||||
if (p.Normlp(2.0) > 0.4 && p.Normlp(2.0) < 0.6)
|
||||
{
|
||||
@@ -70,17 +70,17 @@ double jump_function(const Vector &p)
|
||||
|
||||
// Singular function derived from the Laplacian of the "steep wavefront" problem
|
||||
// in [2].
|
||||
double singular_function(const Vector &p)
|
||||
real_t singular_function(const Vector &p)
|
||||
{
|
||||
double x = p(0), y = p(1);
|
||||
double alpha = 1000.0;
|
||||
double xc = 0.75, yc = 0.5;
|
||||
double r0 = 0.7;
|
||||
double r = sqrt(pow(x - xc,2.0) + pow(y - yc,2.0));
|
||||
double num = - ( alpha - pow(alpha,3) * (pow(r,2) - pow(r0,2)) );
|
||||
double denom = pow(r * ( pow(alpha,2) * pow(r0,2) + pow(alpha,2) * pow(r,2) \
|
||||
real_t x = p(0), y = p(1);
|
||||
real_t alpha = 1000.0;
|
||||
real_t xc = 0.75, yc = 0.5;
|
||||
real_t r0 = 0.7;
|
||||
real_t r = sqrt(pow(x - xc,2.0) + pow(y - yc,2.0));
|
||||
real_t num = - ( alpha - pow(alpha,3) * (pow(r,2) - pow(r0,2)) );
|
||||
real_t denom = pow(r * ( pow(alpha,2) * pow(r0,2) + pow(alpha,2) * pow(r,2) \
|
||||
- 2 * pow(alpha,2) * r0 * r + 1.0 ),2);
|
||||
denom = max(denom,1e-8);
|
||||
denom = std::max(denom, (real_t) 1.0e-8);
|
||||
return num / denom;
|
||||
}
|
||||
|
||||
@@ -97,10 +97,10 @@ int main(int argc, char *argv[])
|
||||
int order = 1;
|
||||
int nc_limit = 1;
|
||||
int max_elems = 1e5;
|
||||
double double_max_elems = double(max_elems);
|
||||
real_t double_max_elems = real_t(max_elems);
|
||||
bool visualization = true;
|
||||
bool nc_simplices = true;
|
||||
double osc_threshold = 1e-3;
|
||||
real_t osc_threshold = 1e-3;
|
||||
int enriched_order = 5;
|
||||
|
||||
OptionsParser args(argc, argv);
|
||||
@@ -199,7 +199,7 @@ int main(int argc, char *argv[])
|
||||
coeffrefiner.PreprocessMesh(pmesh);
|
||||
|
||||
int globalNE = pmesh.GetGlobalNE();
|
||||
double osc = coeffrefiner.GetOsc();
|
||||
real_t osc = coeffrefiner.GetOsc();
|
||||
if (myid == 0)
|
||||
{
|
||||
mfem::out << "\n";
|
||||
|
||||
+28
-28
@@ -39,7 +39,7 @@ using namespace mfem;
|
||||
void E_exact(const Vector &, Vector &);
|
||||
void CurlE_exact(const Vector &, Vector &);
|
||||
void f_exact(const Vector &, Vector &);
|
||||
double freq = 1.0, kappa;
|
||||
real_t freq = 1.0, kappa;
|
||||
int dim;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
@@ -177,7 +177,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
// 13. Compute and print the H(Curl) norm of the error.
|
||||
{
|
||||
double error = sol.ComputeHCurlError(&E, &CurlE);
|
||||
real_t error = sol.ComputeHCurlError(&E, &CurlE);
|
||||
cout << "\n|| E_h - E ||_{H(Curl)} = " << error << '\n' << endl;
|
||||
}
|
||||
|
||||
@@ -376,8 +376,8 @@ void CurlE_exact(const Vector &x, Vector &dE)
|
||||
{
|
||||
if (dim == 1)
|
||||
{
|
||||
double c4 = cos(kappa * x(0) + 0.4 * M_PI);
|
||||
double c9 = cos(kappa * x(0) + 0.9 * M_PI);
|
||||
real_t c4 = cos(kappa * x(0) + 0.4 * M_PI);
|
||||
real_t c9 = cos(kappa * x(0) + 0.9 * M_PI);
|
||||
|
||||
dE(0) = 0.0;
|
||||
dE(1) = -1.3 * c9;
|
||||
@@ -386,9 +386,9 @@ void CurlE_exact(const Vector &x, Vector &dE)
|
||||
}
|
||||
else if (dim == 2)
|
||||
{
|
||||
double c0 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.0 * M_PI);
|
||||
double c4 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.4 * M_PI);
|
||||
double c9 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.9 * M_PI);
|
||||
real_t c0 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.0 * M_PI);
|
||||
real_t c4 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.4 * M_PI);
|
||||
real_t c9 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.9 * M_PI);
|
||||
|
||||
dE(0) = 1.3 * c9;
|
||||
dE(1) = -1.3 * c9;
|
||||
@@ -397,13 +397,13 @@ void CurlE_exact(const Vector &x, Vector &dE)
|
||||
}
|
||||
else
|
||||
{
|
||||
double s0 = sin(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.0 * M_PI);
|
||||
double c0 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.0 * M_PI);
|
||||
double s4 = sin(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.4 * M_PI);
|
||||
double c4 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.4 * M_PI);
|
||||
double c9 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.9 * M_PI);
|
||||
double sk = sin(kappa * x(2));
|
||||
double ck = cos(kappa * x(2));
|
||||
real_t s0 = sin(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.0 * M_PI);
|
||||
real_t c0 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.0 * M_PI);
|
||||
real_t s4 = sin(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.4 * M_PI);
|
||||
real_t c4 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.4 * M_PI);
|
||||
real_t c9 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.9 * M_PI);
|
||||
real_t sk = sin(kappa * x(2));
|
||||
real_t ck = cos(kappa * x(2));
|
||||
|
||||
dE(0) = 1.2 * s4 * sk + 1.3 * M_SQRT1_2 * c9 * ck;
|
||||
dE(1) = -1.1 * s0 * sk - 1.3 * M_SQRT1_2 * c9 * ck;
|
||||
@@ -416,9 +416,9 @@ void f_exact(const Vector &x, Vector &f)
|
||||
{
|
||||
if (dim == 1)
|
||||
{
|
||||
double s0 = sin(kappa * x(0) + 0.0 * M_PI);
|
||||
double s4 = sin(kappa * x(0) + 0.4 * M_PI);
|
||||
double s9 = sin(kappa * x(0) + 0.9 * M_PI);
|
||||
real_t s0 = sin(kappa * x(0) + 0.0 * M_PI);
|
||||
real_t s4 = sin(kappa * x(0) + 0.4 * M_PI);
|
||||
real_t s9 = sin(kappa * x(0) + 0.9 * M_PI);
|
||||
|
||||
f(0) = 2.2 * s0 + 1.2 * M_SQRT1_2 * s4;
|
||||
f(1) = 1.2 * (2.0 + kappa * kappa) * s4 +
|
||||
@@ -427,9 +427,9 @@ void f_exact(const Vector &x, Vector &f)
|
||||
}
|
||||
else if (dim == 2)
|
||||
{
|
||||
double s0 = sin(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.0 * M_PI);
|
||||
double s4 = sin(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.4 * M_PI);
|
||||
double s9 = sin(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.9 * M_PI);
|
||||
real_t s0 = sin(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.0 * M_PI);
|
||||
real_t s4 = sin(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.4 * M_PI);
|
||||
real_t s9 = sin(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.9 * M_PI);
|
||||
|
||||
f(0) = 0.55 * (4.0 + kappa * kappa) * s0 +
|
||||
0.6 * (M_SQRT2 - kappa * kappa) * s4;
|
||||
@@ -440,14 +440,14 @@ void f_exact(const Vector &x, Vector &f)
|
||||
}
|
||||
else
|
||||
{
|
||||
double s0 = sin(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.0 * M_PI);
|
||||
double c0 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.0 * M_PI);
|
||||
double s4 = sin(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.4 * M_PI);
|
||||
double c4 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.4 * M_PI);
|
||||
double s9 = sin(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.9 * M_PI);
|
||||
double c9 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.9 * M_PI);
|
||||
double sk = sin(kappa * x(2));
|
||||
double ck = cos(kappa * x(2));
|
||||
real_t s0 = sin(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.0 * M_PI);
|
||||
real_t c0 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.0 * M_PI);
|
||||
real_t s4 = sin(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.4 * M_PI);
|
||||
real_t c4 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.4 * M_PI);
|
||||
real_t s9 = sin(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.9 * M_PI);
|
||||
real_t c9 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.9 * M_PI);
|
||||
real_t sk = sin(kappa * x(2));
|
||||
real_t ck = cos(kappa * x(2));
|
||||
|
||||
f(0) = 0.55 * (4.0 + 3.0 * kappa * kappa) * s0 * ck +
|
||||
0.6 * (M_SQRT2 - kappa * kappa) * s4 * ck -
|
||||
|
||||
+28
-28
@@ -39,7 +39,7 @@ using namespace mfem;
|
||||
void E_exact(const Vector &, Vector &);
|
||||
void CurlE_exact(const Vector &, Vector &);
|
||||
void f_exact(const Vector &, Vector &);
|
||||
double freq = 1.0, kappa;
|
||||
real_t freq = 1.0, kappa;
|
||||
int dim;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
@@ -224,7 +224,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
// 14. Compute and print the H(Curl) norm of the error.
|
||||
{
|
||||
double error = sol.ComputeHCurlError(&E, &CurlE);
|
||||
real_t error = sol.ComputeHCurlError(&E, &CurlE);
|
||||
if (Mpi::Root())
|
||||
{
|
||||
cout << "\n|| E_h - E ||_{H(Curl)} = " << error << '\n' << endl;
|
||||
@@ -442,8 +442,8 @@ void CurlE_exact(const Vector &x, Vector &dE)
|
||||
{
|
||||
if (dim == 1)
|
||||
{
|
||||
double c4 = cos(kappa * x(0) + 0.4 * M_PI);
|
||||
double c9 = cos(kappa * x(0) + 0.9 * M_PI);
|
||||
real_t c4 = cos(kappa * x(0) + 0.4 * M_PI);
|
||||
real_t c9 = cos(kappa * x(0) + 0.9 * M_PI);
|
||||
|
||||
dE(0) = 0.0;
|
||||
dE(1) = -1.3 * c9;
|
||||
@@ -452,9 +452,9 @@ void CurlE_exact(const Vector &x, Vector &dE)
|
||||
}
|
||||
else if (dim == 2)
|
||||
{
|
||||
double c0 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.0 * M_PI);
|
||||
double c4 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.4 * M_PI);
|
||||
double c9 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.9 * M_PI);
|
||||
real_t c0 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.0 * M_PI);
|
||||
real_t c4 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.4 * M_PI);
|
||||
real_t c9 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.9 * M_PI);
|
||||
|
||||
dE(0) = 1.3 * c9;
|
||||
dE(1) = -1.3 * c9;
|
||||
@@ -463,13 +463,13 @@ void CurlE_exact(const Vector &x, Vector &dE)
|
||||
}
|
||||
else
|
||||
{
|
||||
double s0 = sin(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.0 * M_PI);
|
||||
double c0 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.0 * M_PI);
|
||||
double s4 = sin(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.4 * M_PI);
|
||||
double c4 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.4 * M_PI);
|
||||
double c9 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.9 * M_PI);
|
||||
double sk = sin(kappa * x(2));
|
||||
double ck = cos(kappa * x(2));
|
||||
real_t s0 = sin(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.0 * M_PI);
|
||||
real_t c0 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.0 * M_PI);
|
||||
real_t s4 = sin(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.4 * M_PI);
|
||||
real_t c4 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.4 * M_PI);
|
||||
real_t c9 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.9 * M_PI);
|
||||
real_t sk = sin(kappa * x(2));
|
||||
real_t ck = cos(kappa * x(2));
|
||||
|
||||
dE(0) = 1.2 * s4 * sk + 1.3 * M_SQRT1_2 * c9 * ck;
|
||||
dE(1) = -1.1 * s0 * sk - 1.3 * M_SQRT1_2 * c9 * ck;
|
||||
@@ -482,9 +482,9 @@ void f_exact(const Vector &x, Vector &f)
|
||||
{
|
||||
if (dim == 1)
|
||||
{
|
||||
double s0 = sin(kappa * x(0) + 0.0 * M_PI);
|
||||
double s4 = sin(kappa * x(0) + 0.4 * M_PI);
|
||||
double s9 = sin(kappa * x(0) + 0.9 * M_PI);
|
||||
real_t s0 = sin(kappa * x(0) + 0.0 * M_PI);
|
||||
real_t s4 = sin(kappa * x(0) + 0.4 * M_PI);
|
||||
real_t s9 = sin(kappa * x(0) + 0.9 * M_PI);
|
||||
|
||||
f(0) = 2.2 * s0 + 1.2 * M_SQRT1_2 * s4;
|
||||
f(1) = 1.2 * (2.0 + kappa * kappa) * s4 +
|
||||
@@ -493,9 +493,9 @@ void f_exact(const Vector &x, Vector &f)
|
||||
}
|
||||
else if (dim == 2)
|
||||
{
|
||||
double s0 = sin(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.0 * M_PI);
|
||||
double s4 = sin(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.4 * M_PI);
|
||||
double s9 = sin(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.9 * M_PI);
|
||||
real_t s0 = sin(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.0 * M_PI);
|
||||
real_t s4 = sin(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.4 * M_PI);
|
||||
real_t s9 = sin(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.9 * M_PI);
|
||||
|
||||
f(0) = 0.55 * (4.0 + kappa * kappa) * s0 +
|
||||
0.6 * (M_SQRT2 - kappa * kappa) * s4;
|
||||
@@ -506,14 +506,14 @@ void f_exact(const Vector &x, Vector &f)
|
||||
}
|
||||
else
|
||||
{
|
||||
double s0 = sin(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.0 * M_PI);
|
||||
double c0 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.0 * M_PI);
|
||||
double s4 = sin(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.4 * M_PI);
|
||||
double c4 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.4 * M_PI);
|
||||
double s9 = sin(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.9 * M_PI);
|
||||
double c9 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.9 * M_PI);
|
||||
double sk = sin(kappa * x(2));
|
||||
double ck = cos(kappa * x(2));
|
||||
real_t s0 = sin(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.0 * M_PI);
|
||||
real_t c0 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.0 * M_PI);
|
||||
real_t s4 = sin(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.4 * M_PI);
|
||||
real_t c4 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.4 * M_PI);
|
||||
real_t s9 = sin(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.9 * M_PI);
|
||||
real_t c9 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.9 * M_PI);
|
||||
real_t sk = sin(kappa * x(2));
|
||||
real_t ck = cos(kappa * x(2));
|
||||
|
||||
f(0) = 0.55 * (4.0 + 3.0 * kappa * kappa) * s0 * ck +
|
||||
0.6 * (M_SQRT2 - kappa * kappa) * s4 * ck -
|
||||
|
||||
+18
-18
@@ -35,8 +35,8 @@
|
||||
using namespace std;
|
||||
using namespace mfem;
|
||||
|
||||
double GetVectorMax(int vdim, const ParGridFunction &x);
|
||||
double GetScalarMax(const ParGridFunction &x);
|
||||
real_t GetVectorMax(int vdim, const ParGridFunction &x);
|
||||
real_t GetScalarMax(const ParGridFunction &x);
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
@@ -140,7 +140,7 @@ int main(int argc, char *argv[])
|
||||
// extract the corresponding parallel matrices A and M.
|
||||
HypreParMatrix *A = NULL;
|
||||
HypreParMatrix *M = NULL;
|
||||
double shift = 0.0;
|
||||
real_t shift = 0.0;
|
||||
{
|
||||
DenseMatrix epsilonMat(3);
|
||||
epsilonMat(0,0) = 2.0; epsilonMat(1,1) = 2.0; epsilonMat(2,2) = 2.0;
|
||||
@@ -178,7 +178,7 @@ int main(int argc, char *argv[])
|
||||
m.AddDomainIntegrator(new VectorFEMassIntegrator(epsilon));
|
||||
m.Assemble();
|
||||
// shift the eigenvalue corresponding to eliminated dofs to a large value
|
||||
m.EliminateEssentialBCDiag(ess_bdr, numeric_limits<double>::min());
|
||||
m.EliminateEssentialBCDiag(ess_bdr, numeric_limits<real_t>::min());
|
||||
m.Finalize();
|
||||
|
||||
A = a.ParallelAssemble();
|
||||
@@ -204,7 +204,7 @@ int main(int argc, char *argv[])
|
||||
// 9. Compute the eigenmodes and extract the array of eigenvalues. Define
|
||||
// parallel grid functions to represent each of the eigenmodes returned by
|
||||
// the solver and their derivatives.
|
||||
Array<double> eigenvalues;
|
||||
Array<real_t> eigenvalues;
|
||||
ame->Solve();
|
||||
ame->GetEigenvalues(eigenvalues);
|
||||
ParGridFunction x(&fespace_nd);
|
||||
@@ -308,10 +308,10 @@ int main(int argc, char *argv[])
|
||||
yComp.ProjectCoefficient(yCoef);
|
||||
zComp.ProjectCoefficient(zCoef);
|
||||
|
||||
double max_x = GetScalarMax(xComp);
|
||||
double max_y = GetScalarMax(yComp);
|
||||
double max_z = GetScalarMax(zComp);
|
||||
double max_r = std::max(max_x, std::max(max_y, max_z));
|
||||
real_t max_x = GetScalarMax(xComp);
|
||||
real_t max_y = GetScalarMax(yComp);
|
||||
real_t max_z = GetScalarMax(zComp);
|
||||
real_t max_r = std::max(max_x, std::max(max_y, max_z));
|
||||
|
||||
ostringstream x_cmd;
|
||||
x_cmd << " window_title 'Eigenmode " << i+1 << '/' << nev
|
||||
@@ -368,7 +368,7 @@ int main(int argc, char *argv[])
|
||||
dyComp.ProjectCoefficient(dyCoef);
|
||||
dzComp.ProjectCoefficient(dzCoef);
|
||||
|
||||
double min_d = max_r / (bbMax[0] - bbMin[0]);
|
||||
real_t min_d = max_r / (bbMax[0] - bbMin[0]);
|
||||
|
||||
max_y = GetScalarMax(dyComp);
|
||||
max_z = GetScalarMax(dzComp);
|
||||
@@ -480,9 +480,9 @@ int main(int argc, char *argv[])
|
||||
xyComp.ProjectCoefficient(xyCoef);
|
||||
zComp.ProjectCoefficient(zCoef);
|
||||
|
||||
double max_v = GetVectorMax(2, xyComp);
|
||||
double max_s = GetScalarMax(zComp);
|
||||
double max_r = std::max(max_v, max_s);
|
||||
real_t max_v = GetVectorMax(2, xyComp);
|
||||
real_t max_s = GetScalarMax(zComp);
|
||||
real_t max_r = std::max(max_v, max_s);
|
||||
|
||||
ostringstream xy_cmd;
|
||||
xy_cmd << " window_title 'Eigenmode " << i+1 << '/' << nev
|
||||
@@ -523,7 +523,7 @@ int main(int argc, char *argv[])
|
||||
dxyComp.ProjectCoefficient(dxyCoef);
|
||||
dzComp.ProjectCoefficient(dzCoef);
|
||||
|
||||
double min_d = max_r / std::min(bbMax[0] - bbMin[0],
|
||||
real_t min_d = max_r / std::min(bbMax[0] - bbMin[0],
|
||||
bbMax[1] - bbMin[1]);
|
||||
|
||||
max_v = GetVectorMax(2, dxyComp);
|
||||
@@ -649,17 +649,17 @@ int main(int argc, char *argv[])
|
||||
return 0;
|
||||
}
|
||||
|
||||
double GetVectorMax(int vdim, const ParGridFunction &x)
|
||||
real_t GetVectorMax(int vdim, const ParGridFunction &x)
|
||||
{
|
||||
Vector zeroVec(vdim); zeroVec = 0.0;
|
||||
VectorConstantCoefficient zero(zeroVec);
|
||||
double nrm = x.ComputeMaxError(zero);
|
||||
real_t nrm = x.ComputeMaxError(zero);
|
||||
return nrm;
|
||||
}
|
||||
|
||||
double GetScalarMax(const ParGridFunction &x)
|
||||
real_t GetScalarMax(const ParGridFunction &x)
|
||||
{
|
||||
ConstantCoefficient zero(0.0);
|
||||
double nrm = x.ComputeMaxError(zero);
|
||||
real_t nrm = x.ComputeMaxError(zero);
|
||||
return nrm;
|
||||
}
|
||||
|
||||
+11
-7
@@ -90,7 +90,7 @@ int main(int argc, char *argv[])
|
||||
const char *mesh_file = "../data/star.mesh";
|
||||
int order = 1;
|
||||
int num_refs = 3;
|
||||
double alpha = 0.5;
|
||||
real_t alpha = 0.5;
|
||||
bool visualization = true;
|
||||
bool verification = false;
|
||||
|
||||
@@ -118,13 +118,17 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
args.PrintOptions(cout);
|
||||
|
||||
Array<double> coeffs, poles;
|
||||
#ifdef MFEM_USE_SINGLE
|
||||
MFEM_ABORT("This example is not supported in single precision.");
|
||||
#endif
|
||||
|
||||
Array<real_t> coeffs, poles;
|
||||
int progress_steps = 1;
|
||||
|
||||
// 2. Compute the rational expansion coefficients that define the
|
||||
// integer-order PDEs.
|
||||
const int power_of_laplace = (int)floor(alpha);
|
||||
double exponent_to_approximate = alpha - power_of_laplace;
|
||||
real_t exponent_to_approximate = alpha - power_of_laplace;
|
||||
bool integer_order = false;
|
||||
// Check if alpha is an integer or not.
|
||||
if (abs(exponent_to_approximate) > 1e-12)
|
||||
@@ -135,7 +139,7 @@ int main(int argc, char *argv[])
|
||||
ComputePartialFractionApproximation(exponent_to_approximate, coeffs,
|
||||
poles);
|
||||
|
||||
// If the example is build without LAPACK, the exponent_to_approximate
|
||||
// If the example is built without LAPACK, the exponent_to_approximate
|
||||
// might be modified by the function call above.
|
||||
alpha = exponent_to_approximate + power_of_laplace;
|
||||
}
|
||||
@@ -173,7 +177,7 @@ int main(int argc, char *argv[])
|
||||
// 7. Define diffusion coefficient, load, and solution GridFunction.
|
||||
auto func = [&alpha](const Vector &x)
|
||||
{
|
||||
double val = 1.0;
|
||||
real_t val = 1.0;
|
||||
for (int i=0; i<x.Size(); i++)
|
||||
{
|
||||
val *= sin(M_PI*x(i));
|
||||
@@ -364,7 +368,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
auto solution = [] (const Vector &x)
|
||||
{
|
||||
double val = 1.0;
|
||||
real_t val = 1.0;
|
||||
for (int i=0; i<x.Size(); i++)
|
||||
{
|
||||
val *= sin(M_PI*x(i));
|
||||
@@ -372,7 +376,7 @@ int main(int argc, char *argv[])
|
||||
return val;
|
||||
};
|
||||
FunctionCoefficient sol(solution);
|
||||
double l2_error = u.ComputeL2Error(sol);
|
||||
real_t l2_error = u.ComputeL2Error(sol);
|
||||
|
||||
string analytic_solution,expected_mesh;
|
||||
switch (dim)
|
||||
|
||||
+28
-28
@@ -50,8 +50,8 @@ using namespace mfem;
|
||||
|
||||
See pg. A1501 of Nakatsukasa et al. [1]. */
|
||||
void RationalApproximation_AAA(const Vector &val, const Vector &pt,
|
||||
Array<double> &z, Array<double> &f, Vector &w,
|
||||
double tol, int max_order)
|
||||
Array<real_t> &z, Array<real_t> &f, Vector &w,
|
||||
real_t tol, int max_order)
|
||||
{
|
||||
|
||||
// number of sample points
|
||||
@@ -67,11 +67,11 @@ void RationalApproximation_AAA(const Vector &val, const Vector &pt,
|
||||
DenseMatrix C, Ctemp, A, Am;
|
||||
// auxiliary arrays and vectors
|
||||
Vector f_vec;
|
||||
Array<double> c_i;
|
||||
Array<real_t> c_i;
|
||||
|
||||
// mean of the value vector
|
||||
Vector R(val.Size());
|
||||
double mean_val = val.Sum()/size;
|
||||
real_t mean_val = val.Sum()/size;
|
||||
|
||||
for (int i = 0; i<R.Size(); i++) { R(i) = mean_val; }
|
||||
|
||||
@@ -79,10 +79,10 @@ void RationalApproximation_AAA(const Vector &val, const Vector &pt,
|
||||
{
|
||||
// select next support point
|
||||
int idx = 0;
|
||||
double tmp_max = 0;
|
||||
real_t tmp_max = 0;
|
||||
for (int j = 0; j < size; j++)
|
||||
{
|
||||
double tmp = abs(val(j)-R(j));
|
||||
real_t tmp = abs(val(j)-R(j));
|
||||
if (tmp > tmp_max)
|
||||
{
|
||||
tmp_max = tmp;
|
||||
@@ -98,7 +98,7 @@ void RationalApproximation_AAA(const Vector &val, const Vector &pt,
|
||||
J.DeleteFirst(idx);
|
||||
|
||||
// next column in Cauchy matrix
|
||||
Array<double> C_tmp(size);
|
||||
Array<real_t> C_tmp(size);
|
||||
for (int j = 0; j < size; j++)
|
||||
{
|
||||
C_tmp[j] = 1.0/(pt(j)-pt(idx));
|
||||
@@ -173,7 +173,7 @@ void RationalApproximation_AAA(const Vector &val, const Vector &pt,
|
||||
|
||||
See pg. A1501 of Nakatsukasa et al. [1]. */
|
||||
void ComputePolesAndZeros(const Vector &z, const Vector &f, const Vector &w,
|
||||
Array<double> & poles, Array<double> & zeros, double &scale)
|
||||
Array<real_t> & poles, Array<real_t> & zeros, real_t &scale)
|
||||
{
|
||||
// Initialization
|
||||
poles.SetSize(0);
|
||||
@@ -242,8 +242,8 @@ void ComputePolesAndZeros(const Vector &z, const Vector &f, const Vector &w,
|
||||
@param[in] zeros Array of zeros
|
||||
@param[in] scale Scaling constant
|
||||
@param[out] coeffs Coefficients c_i */
|
||||
void PartialFractionExpansion(double scale, Array<double> & poles,
|
||||
Array<double> & zeros, Array<double> & coeffs)
|
||||
void PartialFractionExpansion(real_t scale, Array<real_t> & poles,
|
||||
Array<real_t> & zeros, Array<real_t> & coeffs)
|
||||
{
|
||||
int psize = poles.Size();
|
||||
int zsize = zeros.Size();
|
||||
@@ -259,13 +259,13 @@ void PartialFractionExpansion(double scale, Array<double> & poles,
|
||||
|
||||
for (int i=0; i<psize; i++)
|
||||
{
|
||||
double tmp_numer=1.0;
|
||||
real_t tmp_numer=1.0;
|
||||
for (int j=0; j<zsize; j++)
|
||||
{
|
||||
tmp_numer *= poles[i]-zeros[j];
|
||||
}
|
||||
|
||||
double tmp_denom=1.0;
|
||||
real_t tmp_denom=1.0;
|
||||
for (int k=0; k<psize; k++)
|
||||
{
|
||||
if (k != i) { tmp_denom *= poles[i]-poles[k]; }
|
||||
@@ -292,10 +292,10 @@ void PartialFractionExpansion(double scale, Array<double> & poles,
|
||||
@a alpha != 0.99, then @a alpha = 0.5 is used by default.
|
||||
|
||||
See pg. A1501 of Nakatsukasa et al. [1]. */
|
||||
void ComputePartialFractionApproximation(double & alpha,
|
||||
Array<double> & coeffs, Array<double> & poles,
|
||||
double lmax = 1000.,
|
||||
double tol=1e-10, int npoints = 1000,
|
||||
void ComputePartialFractionApproximation(real_t & alpha,
|
||||
Array<real_t> & coeffs, Array<real_t> & poles,
|
||||
real_t lmax = 1000.,
|
||||
real_t tol=1e-10, int npoints = 1000,
|
||||
int max_order = 100)
|
||||
{
|
||||
MFEM_VERIFY(alpha < 1., "alpha must be less than 1");
|
||||
@@ -320,26 +320,26 @@ void ComputePartialFractionApproximation(double & alpha,
|
||||
<< "\nThe default is alpha = 0.5.\n" << string(80, '=') << "\n"
|
||||
<< endl;
|
||||
}
|
||||
const double eps = std::numeric_limits<double>::epsilon();
|
||||
const real_t eps = std::numeric_limits<real_t>::epsilon();
|
||||
|
||||
if (abs(alpha - 0.33) < eps)
|
||||
{
|
||||
coeffs = Array<double> ({1.821898e+03, 9.101221e+01, 2.650611e+01,
|
||||
coeffs = Array<real_t> ({1.821898e+03, 9.101221e+01, 2.650611e+01,
|
||||
1.174937e+01, 6.140444e+00, 3.441713e+00,
|
||||
1.985735e+00, 1.162634e+00, 6.891560e-01,
|
||||
4.111574e-01, 2.298736e-01});
|
||||
poles = Array<double> ({-4.155583e+04, -2.956285e+03, -8.331715e+02,
|
||||
poles = Array<real_t> ({-4.155583e+04, -2.956285e+03, -8.331715e+02,
|
||||
-3.139332e+02, -1.303448e+02, -5.563385e+01,
|
||||
-2.356255e+01, -9.595516e+00, -3.552160e+00,
|
||||
-1.032136e+00, -1.241480e-01});
|
||||
}
|
||||
else if (abs(alpha - 0.99) < eps)
|
||||
{
|
||||
coeffs = Array<double>({2.919591e-02, 1.419750e-02, 1.065798e-02,
|
||||
coeffs = Array<real_t>({2.919591e-02, 1.419750e-02, 1.065798e-02,
|
||||
9.395094e-03, 8.915329e-03, 8.822991e-03,
|
||||
9.058247e-03, 9.814521e-03, 1.180396e-02,
|
||||
1.834554e-02, 9.840482e-01});
|
||||
poles = Array<double> ({-1.069683e+04, -1.769370e+03, -5.718374e+02,
|
||||
poles = Array<real_t> ({-1.069683e+04, -1.769370e+03, -5.718374e+02,
|
||||
-2.242095e+02, -9.419132e+01, -4.031012e+01,
|
||||
-1.701525e+01, -6.810088e+00, -2.382810e+00,
|
||||
-5.700059e-01, -1.384324e-03});
|
||||
@@ -350,11 +350,11 @@ void ComputePartialFractionApproximation(double & alpha,
|
||||
{
|
||||
alpha = 0.5;
|
||||
}
|
||||
coeffs = Array<double>({2.290262e+02, 2.641819e+01, 1.005566e+01,
|
||||
coeffs = Array<real_t>({2.290262e+02, 2.641819e+01, 1.005566e+01,
|
||||
5.390411e+00, 3.340725e+00, 2.211205e+00,
|
||||
1.508883e+00, 1.049474e+00, 7.462709e-01,
|
||||
5.482686e-01, 4.232510e-01, 3.578967e-01});
|
||||
poles = Array<double>({-3.168211e+04, -3.236077e+03, -9.868287e+02,
|
||||
poles = Array<real_t>({-3.168211e+04, -3.236077e+03, -9.868287e+02,
|
||||
-3.945597e+02, -1.738889e+02, -7.925178e+01,
|
||||
-3.624992e+01, -1.629196e+01, -6.982956e+00,
|
||||
-2.679984e+00, -7.782607e-01, -7.649166e-02});
|
||||
@@ -372,15 +372,15 @@ void ComputePartialFractionApproximation(double & alpha,
|
||||
|
||||
Vector x(npoints);
|
||||
Vector val(npoints);
|
||||
double dx = lmax / (double)(npoints-1);
|
||||
real_t dx = lmax / (real_t)(npoints-1);
|
||||
for (int i = 0; i<npoints; i++)
|
||||
{
|
||||
x(i) = dx * (double)i;
|
||||
x(i) = dx * (real_t)i;
|
||||
val(i) = pow(x(i),1.-alpha);
|
||||
}
|
||||
|
||||
// Apply triple-A algorithm to f(x) = x^{1-a}
|
||||
Array<double> z, f;
|
||||
Array<real_t> z, f;
|
||||
Vector w;
|
||||
RationalApproximation_AAA(val,x,z,f,w,tol,max_order);
|
||||
|
||||
@@ -389,8 +389,8 @@ void ComputePartialFractionApproximation(double & alpha,
|
||||
vecf.SetDataAndSize(f.GetData(), f.Size());
|
||||
|
||||
// Compute poles and zeros for RA of f(x) = x^{1-a}
|
||||
double scale;
|
||||
Array<double> zeros;
|
||||
real_t scale;
|
||||
Array<real_t> zeros;
|
||||
ComputePolesAndZeros(vecz, vecf, w, poles, zeros, scale);
|
||||
|
||||
// Remove the zero at x=0, thus, delivering a RA for f(x) = x^{-a}
|
||||
|
||||
+10
-6
@@ -96,7 +96,7 @@ int main(int argc, char *argv[])
|
||||
const char *mesh_file = "../data/star.mesh";
|
||||
int order = 1;
|
||||
int num_refs = 3;
|
||||
double alpha = 0.5;
|
||||
real_t alpha = 0.5;
|
||||
bool visualization = true;
|
||||
bool verification = false;
|
||||
|
||||
@@ -127,13 +127,17 @@ int main(int argc, char *argv[])
|
||||
args.PrintOptions(cout);
|
||||
}
|
||||
|
||||
Array<double> coeffs, poles;
|
||||
#ifdef MFEM_USE_SINGLE
|
||||
MFEM_ABORT("This example is not supported in single precision.");
|
||||
#endif
|
||||
|
||||
Array<real_t> coeffs, poles;
|
||||
int progress_steps = 1;
|
||||
|
||||
// 2. Compute the rational expansion coefficients that define the
|
||||
// integer-order PDEs.
|
||||
const int power_of_laplace = floor(alpha);
|
||||
double exponent_to_approximate = alpha - power_of_laplace;
|
||||
real_t exponent_to_approximate = alpha - power_of_laplace;
|
||||
bool integer_order = false;
|
||||
// Check if alpha is an integer or not.
|
||||
if (abs(exponent_to_approximate) > 1e-12)
|
||||
@@ -193,7 +197,7 @@ int main(int argc, char *argv[])
|
||||
// 7. Define diffusion coefficient, load, and solution GridFunction.
|
||||
auto func = [&alpha](const Vector &x)
|
||||
{
|
||||
double val = 1.0;
|
||||
real_t val = 1.0;
|
||||
for (int i=0; i<x.Size(); i++)
|
||||
{
|
||||
val *= sin(M_PI*x(i));
|
||||
@@ -398,7 +402,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
auto solution = [] (const Vector &x)
|
||||
{
|
||||
double val = 1.0;
|
||||
real_t val = 1.0;
|
||||
for (int i=0; i<x.Size(); i++)
|
||||
{
|
||||
val *= sin(M_PI*x(i));
|
||||
@@ -406,7 +410,7 @@ int main(int argc, char *argv[])
|
||||
return val;
|
||||
};
|
||||
FunctionCoefficient sol(solution);
|
||||
double l2_error = u.ComputeL2Error(sol);
|
||||
real_t l2_error = u.ComputeL2Error(sol);
|
||||
|
||||
if (Mpi::Root())
|
||||
{
|
||||
|
||||
+1
-1
@@ -69,7 +69,7 @@ int main(int argc, char *argv[])
|
||||
Array<int> jn_zero_attr;
|
||||
int ref_levels = 1;
|
||||
int order = 1;
|
||||
double delta_const = 1e-6;
|
||||
real_t delta_const = 1e-6;
|
||||
bool mixed = true;
|
||||
bool static_cond = false;
|
||||
const char *device_config = "cpu";
|
||||
|
||||
+1
-1
@@ -73,7 +73,7 @@ int main(int argc, char *argv[])
|
||||
int ser_ref_levels = 1;
|
||||
int par_ref_levels = 1;
|
||||
int order = 1;
|
||||
double delta_const = 1e-6;
|
||||
real_t delta_const = 1e-6;
|
||||
bool mixed = true;
|
||||
bool static_cond = false;
|
||||
bool pa = false;
|
||||
|
||||
+9
-9
@@ -55,9 +55,9 @@
|
||||
using namespace std;
|
||||
using namespace mfem;
|
||||
|
||||
static double mu_ = 1.0;
|
||||
static double epsilon_ = 1.0;
|
||||
static double sigma_ = 2.0;
|
||||
static real_t mu_ = 1.0;
|
||||
static real_t epsilon_ = 1.0;
|
||||
static real_t sigma_ = 2.0;
|
||||
|
||||
void SetPortBC(int prob, int dim, int mode, ParGridFunction &port_bc);
|
||||
|
||||
@@ -77,9 +77,9 @@ int main(int argc, char *argv[])
|
||||
Array<int> port_bc_attr;
|
||||
int prob = 0;
|
||||
int mode = 1;
|
||||
double freq = -1.0;
|
||||
double omega = 2.0 * M_PI;
|
||||
double a_coef = 0.0;
|
||||
real_t freq = -1.0;
|
||||
real_t omega = 2.0 * M_PI;
|
||||
real_t a_coef = 0.0;
|
||||
bool herm_conv = true;
|
||||
bool slu_solver = false;
|
||||
bool visualization = 1;
|
||||
@@ -587,7 +587,7 @@ int main(int argc, char *argv[])
|
||||
int i = 0;
|
||||
while (sol_sock)
|
||||
{
|
||||
double t = (double)(i % num_frames) / num_frames;
|
||||
real_t t = (real_t)(i % num_frames) / num_frames;
|
||||
ostringstream oss;
|
||||
oss << "Harmonic Solution (t = " << t << " T)";
|
||||
|
||||
@@ -637,7 +637,7 @@ void ScalarWaveGuide(int mode, ParGridFunction &x)
|
||||
m.AddDomainIntegrator(new MassIntegrator);
|
||||
m.Assemble();
|
||||
// shift the eigenvalue corresponding to eliminated dofs to a large value
|
||||
m.EliminateEssentialBCDiag(ess_bdr, numeric_limits<double>::min());
|
||||
m.EliminateEssentialBCDiag(ess_bdr, numeric_limits<real_t>::min());
|
||||
m.Finalize();
|
||||
|
||||
HypreParMatrix *A = a.ParallelAssemble();
|
||||
@@ -694,7 +694,7 @@ void VectorWaveGuide(int mode, ParGridFunction &x)
|
||||
m.AddDomainIntegrator(new VectorFEMassIntegrator);
|
||||
m.Assemble();
|
||||
// shift the eigenvalue corresponding to eliminated dofs to a large value
|
||||
m.EliminateEssentialBCDiag(ess_bdr, numeric_limits<double>::min());
|
||||
m.EliminateEssentialBCDiag(ess_bdr, numeric_limits<real_t>::min());
|
||||
m.Finalize();
|
||||
|
||||
HypreParMatrix *A = a.ParallelAssemble();
|
||||
|
||||
+45
-45
@@ -37,8 +37,8 @@
|
||||
using namespace std;
|
||||
using namespace mfem;
|
||||
|
||||
double spherical_obstacle(const Vector &pt);
|
||||
double exact_solution_obstacle(const Vector &pt);
|
||||
real_t spherical_obstacle(const Vector &pt);
|
||||
real_t exact_solution_obstacle(const Vector &pt);
|
||||
void exact_solution_gradient_obstacle(const Vector &pt, Vector &grad);
|
||||
|
||||
class LogarithmGridFunctionCoefficient : public Coefficient
|
||||
@@ -46,14 +46,14 @@ class LogarithmGridFunctionCoefficient : public Coefficient
|
||||
protected:
|
||||
GridFunction *u; // grid function
|
||||
Coefficient *obstacle;
|
||||
double min_val;
|
||||
real_t min_val;
|
||||
|
||||
public:
|
||||
LogarithmGridFunctionCoefficient(GridFunction &u_, Coefficient &obst_,
|
||||
double min_val_=-36)
|
||||
real_t min_val_=-36)
|
||||
: u(&u_), obstacle(&obst_), min_val(min_val_) { }
|
||||
|
||||
virtual double Eval(ElementTransformation &T, const IntegrationPoint &ip);
|
||||
virtual real_t Eval(ElementTransformation &T, const IntegrationPoint &ip);
|
||||
};
|
||||
|
||||
class ExponentialGridFunctionCoefficient : public Coefficient
|
||||
@@ -61,15 +61,15 @@ class ExponentialGridFunctionCoefficient : public Coefficient
|
||||
protected:
|
||||
GridFunction *u;
|
||||
Coefficient *obstacle;
|
||||
double min_val;
|
||||
double max_val;
|
||||
real_t min_val;
|
||||
real_t max_val;
|
||||
|
||||
public:
|
||||
ExponentialGridFunctionCoefficient(GridFunction &u_, Coefficient &obst_,
|
||||
double min_val_=0.0, double max_val_=1e6)
|
||||
real_t min_val_=0.0, real_t max_val_=1e6)
|
||||
: u(&u_), obstacle(&obst_), min_val(min_val_), max_val(max_val_) { }
|
||||
|
||||
virtual double Eval(ElementTransformation &T, const IntegrationPoint &ip);
|
||||
virtual real_t Eval(ElementTransformation &T, const IntegrationPoint &ip);
|
||||
};
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
@@ -78,8 +78,8 @@ int main(int argc, char *argv[])
|
||||
int order = 1;
|
||||
int max_it = 10;
|
||||
int ref_levels = 3;
|
||||
double alpha = 1.0;
|
||||
double tol = 1e-5;
|
||||
real_t alpha = 1.0;
|
||||
real_t tol = 1e-5;
|
||||
bool visualization = true;
|
||||
|
||||
OptionsParser args(argc, argv);
|
||||
@@ -124,7 +124,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
// 3C. Rescale the domain to a unit circle (radius = 1).
|
||||
GridFunction *nodes = mesh.GetNodes();
|
||||
double scale = 2*sqrt(2);
|
||||
real_t scale = 2*sqrt(2);
|
||||
*nodes /= scale;
|
||||
|
||||
// 4. Define the necessary finite element spaces on the mesh.
|
||||
@@ -159,8 +159,8 @@ int main(int argc, char *argv[])
|
||||
// 6. Define an initial guess for the solution.
|
||||
auto IC_func = [](const Vector &x)
|
||||
{
|
||||
double r0 = 1.0;
|
||||
double rr = 0.0;
|
||||
real_t r0 = 1.0;
|
||||
real_t rr = 0.0;
|
||||
for (int i=0; i<x.Size(); i++)
|
||||
{
|
||||
rr += x(i)*x(i);
|
||||
@@ -211,7 +211,7 @@ int main(int argc, char *argv[])
|
||||
// 10. Iterate
|
||||
int k;
|
||||
int total_iterations = 0;
|
||||
double increment_u = 0.1;
|
||||
real_t increment_u = 0.1;
|
||||
for (k = 0; k < max_it; k++)
|
||||
{
|
||||
GridFunction u_tmp(&H1fes);
|
||||
@@ -300,10 +300,10 @@ int main(int argc, char *argv[])
|
||||
delta_psi_gf.MakeRef(&L2fes, x.GetBlock(1), 0);
|
||||
|
||||
u_tmp -= u_gf;
|
||||
double Newton_update_size = u_tmp.ComputeL2Error(zero);
|
||||
real_t Newton_update_size = u_tmp.ComputeL2Error(zero);
|
||||
u_tmp = u_gf;
|
||||
|
||||
double gamma = 1.0;
|
||||
real_t gamma = 1.0;
|
||||
delta_psi_gf *= gamma;
|
||||
psi_gf += delta_psi_gf;
|
||||
|
||||
@@ -337,7 +337,7 @@ int main(int argc, char *argv[])
|
||||
break;
|
||||
}
|
||||
|
||||
double H1_error = u_gf.ComputeH1Error(&exact_coef,&exact_grad_coef);
|
||||
real_t H1_error = u_gf.ComputeH1Error(&exact_coef,&exact_grad_coef);
|
||||
mfem::out << "H1-error (|| u - uₕᵏ||) = " << H1_error << endl;
|
||||
|
||||
}
|
||||
@@ -362,13 +362,13 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
{
|
||||
double L2_error = u_gf.ComputeL2Error(exact_coef);
|
||||
double H1_error = u_gf.ComputeH1Error(&exact_coef,&exact_grad_coef);
|
||||
real_t L2_error = u_gf.ComputeL2Error(exact_coef);
|
||||
real_t H1_error = u_gf.ComputeH1Error(&exact_coef,&exact_grad_coef);
|
||||
|
||||
ExponentialGridFunctionCoefficient u_alt_cf(psi_gf,obstacle);
|
||||
GridFunction u_alt_gf(&L2fes);
|
||||
u_alt_gf.ProjectCoefficient(u_alt_cf);
|
||||
double L2_error_alt = u_alt_gf.ComputeL2Error(exact_coef);
|
||||
real_t L2_error_alt = u_alt_gf.ComputeL2Error(exact_coef);
|
||||
|
||||
mfem::out << "\n Final L2-error (|| u - uₕ||) = " << L2_error <<
|
||||
endl;
|
||||
@@ -380,35 +380,35 @@ int main(int argc, char *argv[])
|
||||
return 0;
|
||||
}
|
||||
|
||||
double LogarithmGridFunctionCoefficient::Eval(ElementTransformation &T,
|
||||
real_t LogarithmGridFunctionCoefficient::Eval(ElementTransformation &T,
|
||||
const IntegrationPoint &ip)
|
||||
{
|
||||
MFEM_ASSERT(u != NULL, "grid function is not set");
|
||||
|
||||
double val = u->GetValue(T, ip) - obstacle->Eval(T, ip);
|
||||
real_t val = u->GetValue(T, ip) - obstacle->Eval(T, ip);
|
||||
return max(min_val, log(val));
|
||||
}
|
||||
|
||||
double ExponentialGridFunctionCoefficient::Eval(ElementTransformation &T,
|
||||
real_t ExponentialGridFunctionCoefficient::Eval(ElementTransformation &T,
|
||||
const IntegrationPoint &ip)
|
||||
{
|
||||
MFEM_ASSERT(u != NULL, "grid function is not set");
|
||||
|
||||
double val = u->GetValue(T, ip);
|
||||
real_t val = u->GetValue(T, ip);
|
||||
return min(max_val, max(min_val, exp(val) + obstacle->Eval(T, ip)));
|
||||
}
|
||||
|
||||
double spherical_obstacle(const Vector &pt)
|
||||
real_t spherical_obstacle(const Vector &pt)
|
||||
{
|
||||
double x = pt(0), y = pt(1);
|
||||
double r = sqrt(x*x + y*y);
|
||||
double r0 = 0.5;
|
||||
double beta = 0.9;
|
||||
real_t x = pt(0), y = pt(1);
|
||||
real_t r = sqrt(x*x + y*y);
|
||||
real_t r0 = 0.5;
|
||||
real_t beta = 0.9;
|
||||
|
||||
double b = r0*beta;
|
||||
double tmp = sqrt(r0*r0 - b*b);
|
||||
double B = tmp + b*b/tmp;
|
||||
double C = -b/tmp;
|
||||
real_t b = r0*beta;
|
||||
real_t tmp = sqrt(r0*r0 - b*b);
|
||||
real_t B = tmp + b*b/tmp;
|
||||
real_t C = -b/tmp;
|
||||
|
||||
if (r > b)
|
||||
{
|
||||
@@ -420,13 +420,13 @@ double spherical_obstacle(const Vector &pt)
|
||||
}
|
||||
}
|
||||
|
||||
double exact_solution_obstacle(const Vector &pt)
|
||||
real_t exact_solution_obstacle(const Vector &pt)
|
||||
{
|
||||
double x = pt(0), y = pt(1);
|
||||
double r = sqrt(x*x + y*y);
|
||||
double r0 = 0.5;
|
||||
double a = 0.348982574111686;
|
||||
double A = -0.340129705945858;
|
||||
real_t x = pt(0), y = pt(1);
|
||||
real_t r = sqrt(x*x + y*y);
|
||||
real_t r0 = 0.5;
|
||||
real_t a = 0.348982574111686;
|
||||
real_t A = -0.340129705945858;
|
||||
|
||||
if (r > a)
|
||||
{
|
||||
@@ -440,11 +440,11 @@ double exact_solution_obstacle(const Vector &pt)
|
||||
|
||||
void exact_solution_gradient_obstacle(const Vector &pt, Vector &grad)
|
||||
{
|
||||
double x = pt(0), y = pt(1);
|
||||
double r = sqrt(x*x + y*y);
|
||||
double r0 = 0.5;
|
||||
double a = 0.348982574111686;
|
||||
double A = -0.340129705945858;
|
||||
real_t x = pt(0), y = pt(1);
|
||||
real_t r = sqrt(x*x + y*y);
|
||||
real_t r0 = 0.5;
|
||||
real_t a = 0.348982574111686;
|
||||
real_t A = -0.340129705945858;
|
||||
|
||||
if (r > a)
|
||||
{
|
||||
|
||||
+45
-45
@@ -37,8 +37,8 @@
|
||||
using namespace std;
|
||||
using namespace mfem;
|
||||
|
||||
double spherical_obstacle(const Vector &pt);
|
||||
double exact_solution_obstacle(const Vector &pt);
|
||||
real_t spherical_obstacle(const Vector &pt);
|
||||
real_t exact_solution_obstacle(const Vector &pt);
|
||||
void exact_solution_gradient_obstacle(const Vector &pt, Vector &grad);
|
||||
|
||||
class LogarithmGridFunctionCoefficient : public Coefficient
|
||||
@@ -46,14 +46,14 @@ class LogarithmGridFunctionCoefficient : public Coefficient
|
||||
protected:
|
||||
GridFunction *u; // grid function
|
||||
Coefficient *obstacle;
|
||||
double min_val;
|
||||
real_t min_val;
|
||||
|
||||
public:
|
||||
LogarithmGridFunctionCoefficient(GridFunction &u_, Coefficient &obst_,
|
||||
double min_val_=-36)
|
||||
real_t min_val_=-36)
|
||||
: u(&u_), obstacle(&obst_), min_val(min_val_) { }
|
||||
|
||||
virtual double Eval(ElementTransformation &T, const IntegrationPoint &ip);
|
||||
virtual real_t Eval(ElementTransformation &T, const IntegrationPoint &ip);
|
||||
};
|
||||
|
||||
class ExponentialGridFunctionCoefficient : public Coefficient
|
||||
@@ -61,15 +61,15 @@ class ExponentialGridFunctionCoefficient : public Coefficient
|
||||
protected:
|
||||
GridFunction *u;
|
||||
Coefficient *obstacle;
|
||||
double min_val;
|
||||
double max_val;
|
||||
real_t min_val;
|
||||
real_t max_val;
|
||||
|
||||
public:
|
||||
ExponentialGridFunctionCoefficient(GridFunction &u_, Coefficient &obst_,
|
||||
double min_val_=0.0, double max_val_=1e6)
|
||||
real_t min_val_=0.0, real_t max_val_=1e6)
|
||||
: u(&u_), obstacle(&obst_), min_val(min_val_), max_val(max_val_) { }
|
||||
|
||||
virtual double Eval(ElementTransformation &T, const IntegrationPoint &ip);
|
||||
virtual real_t Eval(ElementTransformation &T, const IntegrationPoint &ip);
|
||||
};
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
@@ -84,8 +84,8 @@ int main(int argc, char *argv[])
|
||||
int order = 1;
|
||||
int max_it = 10;
|
||||
int ref_levels = 3;
|
||||
double alpha = 1.0;
|
||||
double tol = 1e-5;
|
||||
real_t alpha = 1.0;
|
||||
real_t tol = 1e-5;
|
||||
bool visualization = true;
|
||||
|
||||
OptionsParser args(argc, argv);
|
||||
@@ -136,7 +136,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
// 3C. Rescale the domain to a unit circle (radius = 1).
|
||||
GridFunction *nodes = mesh.GetNodes();
|
||||
double scale = 2*sqrt(2);
|
||||
real_t scale = 2*sqrt(2);
|
||||
*nodes /= scale;
|
||||
|
||||
ParMesh pmesh(MPI_COMM_WORLD, mesh);
|
||||
@@ -192,8 +192,8 @@ int main(int argc, char *argv[])
|
||||
// 6. Define an initial guess for the solution.
|
||||
auto IC_func = [](const Vector &x)
|
||||
{
|
||||
double r0 = 1.0;
|
||||
double rr = 0.0;
|
||||
real_t r0 = 1.0;
|
||||
real_t rr = 0.0;
|
||||
for (int i=0; i<x.Size(); i++)
|
||||
{
|
||||
rr += x(i)*x(i);
|
||||
@@ -243,7 +243,7 @@ int main(int argc, char *argv[])
|
||||
// 10. Iterate
|
||||
int k;
|
||||
int total_iterations = 0;
|
||||
double increment_u = 0.1;
|
||||
real_t increment_u = 0.1;
|
||||
for (k = 0; k < max_it; k++)
|
||||
{
|
||||
ParGridFunction u_tmp(&H1fes);
|
||||
@@ -346,10 +346,10 @@ int main(int argc, char *argv[])
|
||||
delta_psi_gf.SetFromTrueDofs(tx.GetBlock(1));
|
||||
|
||||
u_tmp -= u_gf;
|
||||
double Newton_update_size = u_tmp.ComputeL2Error(zero);
|
||||
real_t Newton_update_size = u_tmp.ComputeL2Error(zero);
|
||||
u_tmp = u_gf;
|
||||
|
||||
double gamma = 1.0;
|
||||
real_t gamma = 1.0;
|
||||
delta_psi_gf *= gamma;
|
||||
psi_gf += delta_psi_gf;
|
||||
|
||||
@@ -391,7 +391,7 @@ int main(int argc, char *argv[])
|
||||
break;
|
||||
}
|
||||
|
||||
double H1_error = u_gf.ComputeH1Error(&exact_coef,&exact_grad_coef);
|
||||
real_t H1_error = u_gf.ComputeH1Error(&exact_coef,&exact_grad_coef);
|
||||
if (myid == 0)
|
||||
{
|
||||
mfem::out << "H1-error (|| u - uₕᵏ||) = " << H1_error << endl;
|
||||
@@ -423,13 +423,13 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
{
|
||||
double L2_error = u_gf.ComputeL2Error(exact_coef);
|
||||
double H1_error = u_gf.ComputeH1Error(&exact_coef,&exact_grad_coef);
|
||||
real_t L2_error = u_gf.ComputeL2Error(exact_coef);
|
||||
real_t H1_error = u_gf.ComputeH1Error(&exact_coef,&exact_grad_coef);
|
||||
|
||||
ExponentialGridFunctionCoefficient u_alt_cf(psi_gf,obstacle);
|
||||
ParGridFunction u_alt_gf(&L2fes);
|
||||
u_alt_gf.ProjectCoefficient(u_alt_cf);
|
||||
double L2_error_alt = u_alt_gf.ComputeL2Error(exact_coef);
|
||||
real_t L2_error_alt = u_alt_gf.ComputeL2Error(exact_coef);
|
||||
|
||||
if (myid == 0)
|
||||
{
|
||||
@@ -444,35 +444,35 @@ int main(int argc, char *argv[])
|
||||
return 0;
|
||||
}
|
||||
|
||||
double LogarithmGridFunctionCoefficient::Eval(ElementTransformation &T,
|
||||
real_t LogarithmGridFunctionCoefficient::Eval(ElementTransformation &T,
|
||||
const IntegrationPoint &ip)
|
||||
{
|
||||
MFEM_ASSERT(u != NULL, "grid function is not set");
|
||||
|
||||
double val = u->GetValue(T, ip) - obstacle->Eval(T, ip);
|
||||
real_t val = u->GetValue(T, ip) - obstacle->Eval(T, ip);
|
||||
return max(min_val, log(val));
|
||||
}
|
||||
|
||||
double ExponentialGridFunctionCoefficient::Eval(ElementTransformation &T,
|
||||
real_t ExponentialGridFunctionCoefficient::Eval(ElementTransformation &T,
|
||||
const IntegrationPoint &ip)
|
||||
{
|
||||
MFEM_ASSERT(u != NULL, "grid function is not set");
|
||||
|
||||
double val = u->GetValue(T, ip);
|
||||
real_t val = u->GetValue(T, ip);
|
||||
return min(max_val, max(min_val, exp(val) + obstacle->Eval(T, ip)));
|
||||
}
|
||||
|
||||
double spherical_obstacle(const Vector &pt)
|
||||
real_t spherical_obstacle(const Vector &pt)
|
||||
{
|
||||
double x = pt(0), y = pt(1);
|
||||
double r = sqrt(x*x + y*y);
|
||||
double r0 = 0.5;
|
||||
double beta = 0.9;
|
||||
real_t x = pt(0), y = pt(1);
|
||||
real_t r = sqrt(x*x + y*y);
|
||||
real_t r0 = 0.5;
|
||||
real_t beta = 0.9;
|
||||
|
||||
double b = r0*beta;
|
||||
double tmp = sqrt(r0*r0 - b*b);
|
||||
double B = tmp + b*b/tmp;
|
||||
double C = -b/tmp;
|
||||
real_t b = r0*beta;
|
||||
real_t tmp = sqrt(r0*r0 - b*b);
|
||||
real_t B = tmp + b*b/tmp;
|
||||
real_t C = -b/tmp;
|
||||
|
||||
if (r > b)
|
||||
{
|
||||
@@ -484,13 +484,13 @@ double spherical_obstacle(const Vector &pt)
|
||||
}
|
||||
}
|
||||
|
||||
double exact_solution_obstacle(const Vector &pt)
|
||||
real_t exact_solution_obstacle(const Vector &pt)
|
||||
{
|
||||
double x = pt(0), y = pt(1);
|
||||
double r = sqrt(x*x + y*y);
|
||||
double r0 = 0.5;
|
||||
double a = 0.348982574111686;
|
||||
double A = -0.340129705945858;
|
||||
real_t x = pt(0), y = pt(1);
|
||||
real_t r = sqrt(x*x + y*y);
|
||||
real_t r0 = 0.5;
|
||||
real_t a = 0.348982574111686;
|
||||
real_t A = -0.340129705945858;
|
||||
|
||||
if (r > a)
|
||||
{
|
||||
@@ -504,11 +504,11 @@ double exact_solution_obstacle(const Vector &pt)
|
||||
|
||||
void exact_solution_gradient_obstacle(const Vector &pt, Vector &grad)
|
||||
{
|
||||
double x = pt(0), y = pt(1);
|
||||
double r = sqrt(x*x + y*y);
|
||||
double r0 = 0.5;
|
||||
double a = 0.348982574111686;
|
||||
double A = -0.340129705945858;
|
||||
real_t x = pt(0), y = pt(1);
|
||||
real_t r = sqrt(x*x + y*y);
|
||||
real_t r0 = 0.5;
|
||||
real_t a = 0.348982574111686;
|
||||
real_t A = -0.340129705945858;
|
||||
|
||||
if (r > a)
|
||||
{
|
||||
|
||||
+24
-24
@@ -67,9 +67,9 @@ using namespace mfem;
|
||||
* @param target_volume θ vol(Ω)
|
||||
* @param tol Newton iteration tolerance
|
||||
* @param max_its Newton maximum iteration number
|
||||
* @return double Final volume, ∫_Ω sigmoid(ψ)
|
||||
* @return real_t Final volume, ∫_Ω sigmoid(ψ)
|
||||
*/
|
||||
double proj(GridFunction &psi, double target_volume, double tol=1e-12,
|
||||
real_t proj(GridFunction &psi, real_t target_volume, real_t tol=1e-12,
|
||||
int max_its=10)
|
||||
{
|
||||
MappedGridFunctionCoefficient sigmoid_psi(&psi, sigmoid);
|
||||
@@ -84,12 +84,12 @@ double proj(GridFunction &psi, double target_volume, double tol=1e-12,
|
||||
for (int k=0; k<max_its; k++) // Newton iteration
|
||||
{
|
||||
int_sigmoid_psi.Assemble(); // Recompute f(c) with updated ψ
|
||||
const double f = int_sigmoid_psi.Sum() - target_volume;
|
||||
const real_t f = int_sigmoid_psi.Sum() - target_volume;
|
||||
|
||||
int_der_sigmoid_psi.Assemble(); // Recompute df(c) with updated ψ
|
||||
const double df = int_der_sigmoid_psi.Sum();
|
||||
const real_t df = int_der_sigmoid_psi.Sum();
|
||||
|
||||
const double dc = -f/df;
|
||||
const real_t dc = -f/df;
|
||||
psi += dc;
|
||||
if (abs(dc) < tol) { done = true; break; }
|
||||
}
|
||||
@@ -179,15 +179,15 @@ int main(int argc, char *argv[])
|
||||
// 1. Parse command-line options.
|
||||
int ref_levels = 5;
|
||||
int order = 2;
|
||||
double alpha = 1.0;
|
||||
double epsilon = 0.01;
|
||||
double vol_fraction = 0.5;
|
||||
real_t alpha = 1.0;
|
||||
real_t epsilon = 0.01;
|
||||
real_t vol_fraction = 0.5;
|
||||
int max_it = 1e3;
|
||||
double itol = 1e-1;
|
||||
double ntol = 1e-4;
|
||||
double rho_min = 1e-6;
|
||||
double lambda = 1.0;
|
||||
double mu = 1.0;
|
||||
real_t itol = 1e-1;
|
||||
real_t ntol = 1e-4;
|
||||
real_t rho_min = 1e-6;
|
||||
real_t lambda = 1.0;
|
||||
real_t mu = 1.0;
|
||||
bool glvis_visualization = true;
|
||||
bool paraview_output = false;
|
||||
|
||||
@@ -239,8 +239,8 @@ int main(int argc, char *argv[])
|
||||
Array<int> vertices;
|
||||
be->GetVertices(vertices);
|
||||
|
||||
double * coords1 = mesh.GetVertex(vertices[0]);
|
||||
double * coords2 = mesh.GetVertex(vertices[1]);
|
||||
real_t * coords1 = mesh.GetVertex(vertices[0]);
|
||||
real_t * coords2 = mesh.GetVertex(vertices[1]);
|
||||
|
||||
Vector center(2);
|
||||
center(0) = 0.5*(coords1[0] + coords2[0]);
|
||||
@@ -312,7 +312,7 @@ int main(int argc, char *argv[])
|
||||
ElasticitySolver->SetupFEM();
|
||||
Vector center(2); center(0) = 2.9; center(1) = 0.5;
|
||||
Vector force(2); force(0) = 0.0; force(1) = -1.0;
|
||||
double r = 0.05;
|
||||
real_t r = 0.05;
|
||||
VolumeForceCoefficient vforce_cf(r,center,force);
|
||||
ElasticitySolver->SetRHSCoefficient(&vforce_cf);
|
||||
ElasticitySolver->SetEssentialBoundary(ess_bdr);
|
||||
@@ -353,8 +353,8 @@ int main(int argc, char *argv[])
|
||||
LinearForm vol_form(&control_fes);
|
||||
vol_form.AddDomainIntegrator(new DomainLFIntegrator(one));
|
||||
vol_form.Assemble();
|
||||
double domain_volume = vol_form(onegf);
|
||||
const double target_volume = domain_volume * vol_fraction;
|
||||
real_t domain_volume = vol_form(onegf);
|
||||
const real_t target_volume = domain_volume * vol_fraction;
|
||||
|
||||
// 10. Connect to GLVis. Prepare for VisIt output.
|
||||
char vishost[] = "localhost";
|
||||
@@ -385,7 +385,7 @@ int main(int argc, char *argv[])
|
||||
// 11. Iterate:
|
||||
for (int k = 1; k <= max_it; k++)
|
||||
{
|
||||
if (k > 1) { alpha *= ((double) k) / ((double) k-1); }
|
||||
if (k > 1) { alpha *= ((real_t) k) / ((real_t) k-1); }
|
||||
|
||||
mfem::out << "\nStep = " << k << std::endl;
|
||||
|
||||
@@ -422,14 +422,14 @@ int main(int argc, char *argv[])
|
||||
|
||||
// Step 5 - Update design variable ψ ← proj(ψ - αG)
|
||||
psi.Add(-alpha, grad);
|
||||
const double material_volume = proj(psi, target_volume);
|
||||
const real_t material_volume = proj(psi, target_volume);
|
||||
|
||||
// Compute ||ρ - ρ_old|| in control fes.
|
||||
double norm_increment = zerogf.ComputeL1Error(succ_diff_rho);
|
||||
double norm_reduced_gradient = norm_increment/alpha;
|
||||
real_t norm_increment = zerogf.ComputeL1Error(succ_diff_rho);
|
||||
real_t norm_reduced_gradient = norm_increment/alpha;
|
||||
psi_old = psi;
|
||||
|
||||
double compliance = (*(ElasticitySolver->GetLinearForm()))(u);
|
||||
real_t compliance = (*(ElasticitySolver->GetLinearForm()))(u);
|
||||
mfem::out << "norm of the reduced gradient = " << norm_reduced_gradient <<
|
||||
std::endl;
|
||||
mfem::out << "norm of the increment = " << norm_increment << endl;
|
||||
@@ -449,7 +449,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
rho_gf.ProjectCoefficient(rho);
|
||||
paraview_dc.SetCycle(k);
|
||||
paraview_dc.SetTime((double)k);
|
||||
paraview_dc.SetTime((real_t)k);
|
||||
paraview_dc.Save();
|
||||
}
|
||||
|
||||
|
||||
+40
-40
@@ -9,15 +9,15 @@ namespace mfem
|
||||
{
|
||||
|
||||
/// @brief Inverse sigmoid function
|
||||
double inv_sigmoid(double x)
|
||||
real_t inv_sigmoid(real_t x)
|
||||
{
|
||||
double tol = 1e-12;
|
||||
x = std::min(std::max(tol,x),1.0-tol);
|
||||
real_t tol = 1e-12;
|
||||
x = std::min(std::max(tol,x), real_t(1.0)-tol);
|
||||
return std::log(x/(1.0-x));
|
||||
}
|
||||
|
||||
/// @brief Sigmoid function
|
||||
double sigmoid(double x)
|
||||
real_t sigmoid(real_t x)
|
||||
{
|
||||
if (x >= 0)
|
||||
{
|
||||
@@ -30,9 +30,9 @@ double sigmoid(double x)
|
||||
}
|
||||
|
||||
/// @brief Derivative of sigmoid function
|
||||
double der_sigmoid(double x)
|
||||
real_t der_sigmoid(real_t x)
|
||||
{
|
||||
double tmp = sigmoid(-x);
|
||||
real_t tmp = sigmoid(-x);
|
||||
return tmp - std::pow(tmp,2);
|
||||
}
|
||||
|
||||
@@ -40,24 +40,24 @@ double der_sigmoid(double x)
|
||||
class MappedGridFunctionCoefficient : public GridFunctionCoefficient
|
||||
{
|
||||
protected:
|
||||
std::function<double(const double)> fun; // f:R → R
|
||||
std::function<real_t(const real_t)> fun; // f:R → R
|
||||
public:
|
||||
MappedGridFunctionCoefficient()
|
||||
:GridFunctionCoefficient(),
|
||||
fun([](double x) {return x;}) {}
|
||||
fun([](real_t x) {return x;}) {}
|
||||
MappedGridFunctionCoefficient(const GridFunction *gf,
|
||||
std::function<double(const double)> fun_,
|
||||
std::function<real_t(const real_t)> fun_,
|
||||
int comp=1)
|
||||
:GridFunctionCoefficient(gf, comp),
|
||||
fun(fun_) {}
|
||||
|
||||
|
||||
virtual double Eval(ElementTransformation &T,
|
||||
virtual real_t Eval(ElementTransformation &T,
|
||||
const IntegrationPoint &ip)
|
||||
{
|
||||
return fun(GridFunctionCoefficient::Eval(T, ip));
|
||||
}
|
||||
void SetFunction(std::function<double(const double)> fun_) { fun = fun_; }
|
||||
void SetFunction(std::function<real_t(const real_t)> fun_) { fun = fun_; }
|
||||
};
|
||||
|
||||
|
||||
@@ -67,30 +67,30 @@ class DiffMappedGridFunctionCoefficient : public GridFunctionCoefficient
|
||||
protected:
|
||||
const GridFunction *OtherGridF;
|
||||
GridFunctionCoefficient OtherGridF_cf;
|
||||
std::function<double(const double)> fun; // f:R → R
|
||||
std::function<real_t(const real_t)> fun; // f:R → R
|
||||
public:
|
||||
DiffMappedGridFunctionCoefficient()
|
||||
:GridFunctionCoefficient(),
|
||||
OtherGridF(nullptr),
|
||||
OtherGridF_cf(),
|
||||
fun([](double x) {return x;}) {}
|
||||
fun([](real_t x) {return x;}) {}
|
||||
DiffMappedGridFunctionCoefficient(const GridFunction *gf,
|
||||
const GridFunction *other_gf,
|
||||
std::function<double(const double)> fun_,
|
||||
std::function<real_t(const real_t)> fun_,
|
||||
int comp=1)
|
||||
:GridFunctionCoefficient(gf, comp),
|
||||
OtherGridF(other_gf),
|
||||
OtherGridF_cf(OtherGridF),
|
||||
fun(fun_) {}
|
||||
|
||||
virtual double Eval(ElementTransformation &T,
|
||||
virtual real_t Eval(ElementTransformation &T,
|
||||
const IntegrationPoint &ip)
|
||||
{
|
||||
const double value1 = fun(GridFunctionCoefficient::Eval(T, ip));
|
||||
const double value2 = fun(OtherGridF_cf.Eval(T, ip));
|
||||
const real_t value1 = fun(GridFunctionCoefficient::Eval(T, ip));
|
||||
const real_t value2 = fun(OtherGridF_cf.Eval(T, ip));
|
||||
return value1 - value2;
|
||||
}
|
||||
void SetFunction(std::function<double(const double)> fun_) { fun = fun_; }
|
||||
void SetFunction(std::function<real_t(const real_t)> fun_) { fun = fun_; }
|
||||
};
|
||||
|
||||
/// @brief Solid isotropic material penalization (SIMP) coefficient
|
||||
@@ -98,20 +98,20 @@ class SIMPInterpolationCoefficient : public Coefficient
|
||||
{
|
||||
protected:
|
||||
GridFunction *rho_filter;
|
||||
double min_val;
|
||||
double max_val;
|
||||
double exponent;
|
||||
real_t min_val;
|
||||
real_t max_val;
|
||||
real_t exponent;
|
||||
|
||||
public:
|
||||
SIMPInterpolationCoefficient(GridFunction *rho_filter_, double min_val_= 1e-6,
|
||||
double max_val_ = 1.0, double exponent_ = 3)
|
||||
SIMPInterpolationCoefficient(GridFunction *rho_filter_, real_t min_val_= 1e-6,
|
||||
real_t max_val_ = 1.0, real_t exponent_ = 3)
|
||||
: rho_filter(rho_filter_), min_val(min_val_), max_val(max_val_),
|
||||
exponent(exponent_) { }
|
||||
|
||||
virtual double Eval(ElementTransformation &T, const IntegrationPoint &ip)
|
||||
virtual real_t Eval(ElementTransformation &T, const IntegrationPoint &ip)
|
||||
{
|
||||
double val = rho_filter->GetValue(T, ip);
|
||||
double coeff = min_val + pow(val,exponent)*(max_val-min_val);
|
||||
real_t val = rho_filter->GetValue(T, ip);
|
||||
real_t coeff = min_val + pow(val,exponent)*(max_val-min_val);
|
||||
return coeff;
|
||||
}
|
||||
};
|
||||
@@ -126,13 +126,13 @@ protected:
|
||||
GridFunction *u = nullptr; // displacement
|
||||
GridFunction *rho_filter = nullptr; // filter density
|
||||
DenseMatrix grad; // auxiliary matrix, used in Eval
|
||||
double exponent;
|
||||
double rho_min;
|
||||
real_t exponent;
|
||||
real_t rho_min;
|
||||
|
||||
public:
|
||||
StrainEnergyDensityCoefficient(Coefficient *lambda_, Coefficient *mu_,
|
||||
GridFunction * u_, GridFunction * rho_filter_, double rho_min_=1e-6,
|
||||
double exponent_ = 3.0)
|
||||
GridFunction * u_, GridFunction * rho_filter_, real_t rho_min_=1e-6,
|
||||
real_t exponent_ = 3.0)
|
||||
: lambda(lambda_), mu(mu_), u(u_), rho_filter(rho_filter_),
|
||||
exponent(exponent_), rho_min(rho_min_)
|
||||
{
|
||||
@@ -142,13 +142,13 @@ public:
|
||||
MFEM_ASSERT(rho_filter, "density field is not set");
|
||||
}
|
||||
|
||||
virtual double Eval(ElementTransformation &T, const IntegrationPoint &ip)
|
||||
virtual real_t Eval(ElementTransformation &T, const IntegrationPoint &ip)
|
||||
{
|
||||
double L = lambda->Eval(T, ip);
|
||||
double M = mu->Eval(T, ip);
|
||||
real_t L = lambda->Eval(T, ip);
|
||||
real_t M = mu->Eval(T, ip);
|
||||
u->GetVectorGradient(T, grad);
|
||||
double div_u = grad.Trace();
|
||||
double density = L*div_u*div_u;
|
||||
real_t div_u = grad.Trace();
|
||||
real_t density = L*div_u*div_u;
|
||||
int dim = T.GetSpaceDim();
|
||||
for (int i=0; i<dim; i++)
|
||||
{
|
||||
@@ -157,7 +157,7 @@ public:
|
||||
density += M*grad(i,j)*(grad(i,j)+grad(j,i));
|
||||
}
|
||||
}
|
||||
double val = rho_filter->GetValue(T,ip);
|
||||
real_t val = rho_filter->GetValue(T,ip);
|
||||
|
||||
return -exponent * pow(val, exponent-1.0) * (1-rho_min) * density;
|
||||
}
|
||||
@@ -167,11 +167,11 @@ public:
|
||||
class VolumeForceCoefficient : public VectorCoefficient
|
||||
{
|
||||
private:
|
||||
double r;
|
||||
real_t r;
|
||||
Vector center;
|
||||
Vector force;
|
||||
public:
|
||||
VolumeForceCoefficient(double r_,Vector & center_, Vector & force_) :
|
||||
VolumeForceCoefficient(real_t r_,Vector & center_, Vector & force_) :
|
||||
VectorCoefficient(center_.Size()), r(r_), center(center_), force(force_) { }
|
||||
|
||||
using VectorCoefficient::Eval;
|
||||
@@ -186,7 +186,7 @@ public:
|
||||
xx[i]=xx[i]-center[i];
|
||||
}
|
||||
|
||||
double cr=xx.Norml2();
|
||||
real_t cr=xx.Norml2();
|
||||
V.SetSize(T.GetDimension());
|
||||
if (cr <= r)
|
||||
{
|
||||
@@ -198,7 +198,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void Set(double r_,Vector & center_, Vector & force_)
|
||||
void Set(real_t r_,Vector & center_, Vector & force_)
|
||||
{
|
||||
r=r_;
|
||||
center = center_;
|
||||
|
||||
+33
-30
@@ -66,9 +66,9 @@ using namespace mfem;
|
||||
* @param target_volume θ vol(Ω)
|
||||
* @param tol Newton iteration tolerance
|
||||
* @param max_its Newton maximum iteration number
|
||||
* @return double Final volume, ∫_Ω sigmoid(ψ)
|
||||
* @return real_t Final volume, ∫_Ω sigmoid(ψ)
|
||||
*/
|
||||
double proj(ParGridFunction &psi, double target_volume, double tol=1e-12,
|
||||
real_t proj(ParGridFunction &psi, real_t target_volume, real_t tol=1e-12,
|
||||
int max_its=10)
|
||||
{
|
||||
MappedGridFunctionCoefficient sigmoid_psi(&psi, sigmoid);
|
||||
@@ -83,15 +83,17 @@ double proj(ParGridFunction &psi, double target_volume, double tol=1e-12,
|
||||
for (int k=0; k<max_its; k++) // Newton iteration
|
||||
{
|
||||
int_sigmoid_psi.Assemble(); // Recompute f(c) with updated ψ
|
||||
double f = int_sigmoid_psi.Sum();
|
||||
MPI_Allreduce(MPI_IN_PLACE, &f, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD);
|
||||
real_t f = int_sigmoid_psi.Sum();
|
||||
MPI_Allreduce(MPI_IN_PLACE, &f, 1, MPITypeMap<real_t>::mpi_type,
|
||||
MPI_SUM, MPI_COMM_WORLD);
|
||||
f -= target_volume;
|
||||
|
||||
int_der_sigmoid_psi.Assemble(); // Recompute df(c) with updated ψ
|
||||
double df = int_der_sigmoid_psi.Sum();
|
||||
MPI_Allreduce(MPI_IN_PLACE, &df, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD);
|
||||
real_t df = int_der_sigmoid_psi.Sum();
|
||||
MPI_Allreduce(MPI_IN_PLACE, &df, 1, MPITypeMap<real_t>::mpi_type,
|
||||
MPI_SUM, MPI_COMM_WORLD);
|
||||
|
||||
const double dc = -f/df;
|
||||
const real_t dc = -f/df;
|
||||
psi += dc;
|
||||
if (abs(dc) < tol) { done = true; break; }
|
||||
}
|
||||
@@ -101,9 +103,9 @@ double proj(ParGridFunction &psi, double target_volume, double tol=1e-12,
|
||||
"Result may not be accurate.");
|
||||
}
|
||||
int_sigmoid_psi.Assemble();
|
||||
double material_volume = int_sigmoid_psi.Sum();
|
||||
MPI_Allreduce(MPI_IN_PLACE, &material_volume, 1, MPI_DOUBLE, MPI_SUM,
|
||||
MPI_COMM_WORLD);
|
||||
real_t material_volume = int_sigmoid_psi.Sum();
|
||||
MPI_Allreduce(MPI_IN_PLACE, &material_volume, 1,
|
||||
MPITypeMap<real_t>::mpi_type, MPI_SUM, MPI_COMM_WORLD);
|
||||
return material_volume;
|
||||
}
|
||||
|
||||
@@ -190,15 +192,15 @@ int main(int argc, char *argv[])
|
||||
// 1. Parse command-line options.
|
||||
int ref_levels = 5;
|
||||
int order = 2;
|
||||
double alpha = 1.0;
|
||||
double epsilon = 0.01;
|
||||
double vol_fraction = 0.5;
|
||||
real_t alpha = 1.0;
|
||||
real_t epsilon = 0.01;
|
||||
real_t vol_fraction = 0.5;
|
||||
int max_it = 1e3;
|
||||
double itol = 1e-1;
|
||||
double ntol = 1e-4;
|
||||
double rho_min = 1e-6;
|
||||
double lambda = 1.0;
|
||||
double mu = 1.0;
|
||||
real_t itol = 1e-1;
|
||||
real_t ntol = 1e-4;
|
||||
real_t rho_min = 1e-6;
|
||||
real_t lambda = 1.0;
|
||||
real_t mu = 1.0;
|
||||
bool glvis_visualization = true;
|
||||
bool paraview_output = false;
|
||||
|
||||
@@ -258,8 +260,8 @@ int main(int argc, char *argv[])
|
||||
Array<int> vertices;
|
||||
be->GetVertices(vertices);
|
||||
|
||||
double * coords1 = mesh.GetVertex(vertices[0]);
|
||||
double * coords2 = mesh.GetVertex(vertices[1]);
|
||||
real_t * coords1 = mesh.GetVertex(vertices[0]);
|
||||
real_t * coords2 = mesh.GetVertex(vertices[1]);
|
||||
|
||||
Vector center(2);
|
||||
center(0) = 0.5*(coords1[0] + coords2[0]);
|
||||
@@ -337,7 +339,7 @@ int main(int argc, char *argv[])
|
||||
ElasticitySolver->SetupFEM();
|
||||
Vector center(2); center(0) = 2.9; center(1) = 0.5;
|
||||
Vector force(2); force(0) = 0.0; force(1) = -1.0;
|
||||
double r = 0.05;
|
||||
real_t r = 0.05;
|
||||
VolumeForceCoefficient vforce_cf(r,center,force);
|
||||
ElasticitySolver->SetRHSCoefficient(&vforce_cf);
|
||||
ElasticitySolver->SetEssentialBoundary(ess_bdr);
|
||||
@@ -378,8 +380,8 @@ int main(int argc, char *argv[])
|
||||
ParLinearForm vol_form(&control_fes);
|
||||
vol_form.AddDomainIntegrator(new DomainLFIntegrator(one));
|
||||
vol_form.Assemble();
|
||||
double domain_volume = vol_form(onegf);
|
||||
const double target_volume = domain_volume * vol_fraction;
|
||||
real_t domain_volume = vol_form(onegf);
|
||||
const real_t target_volume = domain_volume * vol_fraction;
|
||||
|
||||
// 10. Connect to GLVis. Prepare for VisIt output.
|
||||
char vishost[] = "localhost";
|
||||
@@ -410,7 +412,7 @@ int main(int argc, char *argv[])
|
||||
// 11. Iterate:
|
||||
for (int k = 1; k <= max_it; k++)
|
||||
{
|
||||
if (k > 1) { alpha *= ((double) k) / ((double) k-1); }
|
||||
if (k > 1) { alpha *= ((real_t) k) / ((real_t) k-1); }
|
||||
|
||||
if (myid == 0)
|
||||
{
|
||||
@@ -450,15 +452,16 @@ int main(int argc, char *argv[])
|
||||
|
||||
// Step 5 - Update design variable ψ ← proj(ψ - αG)
|
||||
psi.Add(-alpha, grad);
|
||||
const double material_volume = proj(psi, target_volume);
|
||||
const real_t material_volume = proj(psi, target_volume);
|
||||
|
||||
// Compute ||ρ - ρ_old|| in control fes.
|
||||
double norm_increment = zerogf.ComputeL1Error(succ_diff_rho);
|
||||
double norm_reduced_gradient = norm_increment/alpha;
|
||||
real_t norm_increment = zerogf.ComputeL1Error(succ_diff_rho);
|
||||
real_t norm_reduced_gradient = norm_increment/alpha;
|
||||
psi_old = psi;
|
||||
|
||||
double compliance = (*(ElasticitySolver->GetLinearForm()))(u);
|
||||
MPI_Allreduce(MPI_IN_PLACE,&compliance,1,MPI_DOUBLE,MPI_SUM,MPI_COMM_WORLD);
|
||||
real_t compliance = (*(ElasticitySolver->GetLinearForm()))(u);
|
||||
MPI_Allreduce(MPI_IN_PLACE, &compliance, 1, MPITypeMap<real_t>::mpi_type,
|
||||
MPI_SUM, MPI_COMM_WORLD);
|
||||
if (myid == 0)
|
||||
{
|
||||
mfem::out << "norm of the reduced gradient = " << norm_reduced_gradient << endl;
|
||||
@@ -480,7 +483,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
rho_gf.ProjectCoefficient(rho);
|
||||
paraview_dc.SetCycle(k);
|
||||
paraview_dc.SetTime((double)k);
|
||||
paraview_dc.SetTime((real_t)k);
|
||||
paraview_dc.Save();
|
||||
}
|
||||
|
||||
|
||||
+11
-11
@@ -46,7 +46,7 @@ enum class IntegrationType { Volumetric1D, Surface2D, Volumetric2D,
|
||||
IntegrationType itype;
|
||||
|
||||
/// @brief Level-set function defining the implicit interface
|
||||
double lvlset(const Vector& X)
|
||||
real_t lvlset(const Vector& X)
|
||||
{
|
||||
switch (itype)
|
||||
{
|
||||
@@ -66,7 +66,7 @@ double lvlset(const Vector& X)
|
||||
}
|
||||
|
||||
/// @brief Function that should be integrated
|
||||
double integrand(const Vector& X)
|
||||
real_t integrand(const Vector& X)
|
||||
{
|
||||
switch (itype)
|
||||
{
|
||||
@@ -86,7 +86,7 @@ double integrand(const Vector& X)
|
||||
}
|
||||
|
||||
/// @brief Analytic surface integral
|
||||
double Surface()
|
||||
real_t Surface()
|
||||
{
|
||||
switch (itype)
|
||||
{
|
||||
@@ -106,7 +106,7 @@ double Surface()
|
||||
}
|
||||
|
||||
/// @brief Analytic volume integral over subdomain with positive level-set
|
||||
double Volume()
|
||||
real_t Volume()
|
||||
{
|
||||
switch (itype)
|
||||
{
|
||||
@@ -424,7 +424,7 @@ public:
|
||||
for (int ip = 0; ip < SIntRule->GetNPoints(); ip++)
|
||||
{
|
||||
Tr.SetIntPoint((&(SIntRule->IntPoint(ip))));
|
||||
double val = Tr.Weight() * Q.Eval(Tr, SIntRule->IntPoint(ip));
|
||||
real_t val = Tr.Weight() * Q.Eval(Tr, SIntRule->IntPoint(ip));
|
||||
el.CalcShape(SIntRule->IntPoint(ip), shape);
|
||||
add(elvect, SIntRule->IntPoint(ip).weight * val, shape, elvect);
|
||||
}
|
||||
@@ -492,7 +492,7 @@ public:
|
||||
for (int ip = 0; ip < CIntRule->GetNPoints(); ip++)
|
||||
{
|
||||
Tr.SetIntPoint((&(CIntRule->IntPoint(ip))));
|
||||
double val = Tr.Weight()
|
||||
real_t val = Tr.Weight()
|
||||
* Q.Eval(Tr, CIntRule->IntPoint(ip));
|
||||
el.CalcPhysShape(Tr, shape);
|
||||
add(elvect, CIntRule->IntPoint(ip).weight * val, shape, elvect);
|
||||
@@ -504,7 +504,7 @@ public:
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
#ifndef MFEM_USE_LAPACK
|
||||
cout << "MFEM must be build with LAPACK for this example." << endl;
|
||||
cout << "MFEM must be built with LAPACK for this example." << endl;
|
||||
return EXIT_FAILURE;
|
||||
#else
|
||||
// 1. Parse he command-line options.
|
||||
@@ -636,11 +636,11 @@ int main(int argc, char *argv[])
|
||||
cout << "Mesh size dx: ";
|
||||
if (itype != IntegrationType::Volumetric1D)
|
||||
{
|
||||
cout << 3.2 / pow(2., (double)ref_levels) << endl;
|
||||
cout << 3.2 / pow(2., (real_t)ref_levels) << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
cout << .25 / pow(2., (double)ref_levels) << endl;
|
||||
cout << .25 / pow(2., (real_t)ref_levels) << endl;
|
||||
}
|
||||
if (itype == IntegrationType::Surface2D
|
||||
|| itype == IntegrationType::Volumetric2D)
|
||||
@@ -652,7 +652,7 @@ int main(int argc, char *argv[])
|
||||
cout << "============================================" << endl;
|
||||
cout << "Computed value of surface integral: " << surface.Sum() << endl;
|
||||
cout << "True value of surface integral: " << Surface() << endl;
|
||||
cout << "Absolut Error (Surface): ";
|
||||
cout << "Absolute Error (Surface): ";
|
||||
cout << abs(surface.Sum() - Surface()) << endl;
|
||||
cout << "Relative Error (Surface): ";
|
||||
cout << abs(surface.Sum() - Surface()) / Surface() << endl;
|
||||
@@ -663,7 +663,7 @@ int main(int argc, char *argv[])
|
||||
cout << "--------------------------------------------" << endl;
|
||||
cout << "Computed value of volume integral: " << volume.Sum() << endl;
|
||||
cout << "True value of volume integral: " << Volume() << endl;
|
||||
cout << "Absolut Error (Volume): ";
|
||||
cout << "Absolute Error (Volume): ";
|
||||
cout << abs(volume.Sum() - Volume()) << endl;
|
||||
cout << "Relative Error (Volume): ";
|
||||
cout << abs(volume.Sum() - Volume()) / Volume() << endl;
|
||||
|
||||
+2
-2
@@ -55,7 +55,7 @@ using namespace mfem;
|
||||
// Exact solution, E, and r.h.s., f. See below for implementation.
|
||||
void E_exact(const Vector &, Vector &);
|
||||
void f_exact(const Vector &, Vector &);
|
||||
double freq = 1.0, kappa;
|
||||
real_t freq = 1.0, kappa;
|
||||
int dim;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
@@ -263,7 +263,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
// 15. Compute and print the L^2 norm of the error.
|
||||
{
|
||||
double error = x.ComputeL2Error(E);
|
||||
real_t error = x.ComputeL2Error(E);
|
||||
if (myid == 0)
|
||||
{
|
||||
cout << "\n|| E_h - E ||_{L^2} = " << error << '\n' << endl;
|
||||
|
||||
+8
-8
@@ -54,7 +54,7 @@ using namespace mfem;
|
||||
// Exact solution, F, and r.h.s., f. See below for implementation.
|
||||
void F_exact(const Vector &, Vector &);
|
||||
void f_exact(const Vector &, Vector &);
|
||||
double freq = 1.0, kappa;
|
||||
real_t freq = 1.0, kappa;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
@@ -269,9 +269,9 @@ void F_exact(const Vector &p, Vector &F)
|
||||
{
|
||||
int dim = p.Size();
|
||||
|
||||
double x = p(0);
|
||||
double y = p(1);
|
||||
// double z = (dim == 3) ? p(2) : 0.0; // Uncomment if F is changed to depend on z
|
||||
real_t x = p(0);
|
||||
real_t y = p(1);
|
||||
// real_t z = (dim == 3) ? p(2) : 0.0; // Uncomment if F is changed to depend on z
|
||||
|
||||
F(0) = cos(kappa*x)*sin(kappa*y);
|
||||
F(1) = cos(kappa*y)*sin(kappa*x);
|
||||
@@ -286,11 +286,11 @@ void f_exact(const Vector &p, Vector &f)
|
||||
{
|
||||
int dim = p.Size();
|
||||
|
||||
double x = p(0);
|
||||
double y = p(1);
|
||||
// double z = (dim == 3) ? p(2) : 0.0; // Uncomment if f is changed to depend on z
|
||||
real_t x = p(0);
|
||||
real_t y = p(1);
|
||||
// real_t z = (dim == 3) ? p(2) : 0.0; // Uncomment if f is changed to depend on z
|
||||
|
||||
double temp = 1 + 2*kappa*kappa;
|
||||
real_t temp = 1 + 2*kappa*kappa;
|
||||
|
||||
f(0) = temp*cos(kappa*x)*sin(kappa*y);
|
||||
f(1) = temp*cos(kappa*y)*sin(kappa*x);
|
||||
|
||||
+9
-9
@@ -54,7 +54,7 @@ using namespace mfem;
|
||||
// Exact solution, F, and r.h.s., f. See below for implementation.
|
||||
void F_exact(const Vector &, Vector &);
|
||||
void f_exact(const Vector &, Vector &);
|
||||
double freq = 1.0, kappa;
|
||||
real_t freq = 1.0, kappa;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
@@ -255,7 +255,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
// 15. Compute and print the L^2 norm of the error.
|
||||
{
|
||||
double error = x.ComputeL2Error(F);
|
||||
real_t error = x.ComputeL2Error(F);
|
||||
if (myid == 0)
|
||||
{
|
||||
cout << "\n|| F_h - F ||_{L^2} = " << error << '\n' << endl;
|
||||
@@ -311,9 +311,9 @@ void F_exact(const Vector &p, Vector &F)
|
||||
{
|
||||
int dim = p.Size();
|
||||
|
||||
double x = p(0);
|
||||
double y = p(1);
|
||||
// double z = (dim == 3) ? p(2) : 0.0; // Uncomment if F is changed to depend on z
|
||||
real_t x = p(0);
|
||||
real_t y = p(1);
|
||||
// real_t z = (dim == 3) ? p(2) : 0.0; // Uncomment if F is changed to depend on z
|
||||
|
||||
F(0) = cos(kappa*x)*sin(kappa*y);
|
||||
F(1) = cos(kappa*y)*sin(kappa*x);
|
||||
@@ -328,11 +328,11 @@ void f_exact(const Vector &p, Vector &f)
|
||||
{
|
||||
int dim = p.Size();
|
||||
|
||||
double x = p(0);
|
||||
double y = p(1);
|
||||
// double z = (dim == 3) ? p(2) : 0.0; // Uncomment if f is changed to depend on z
|
||||
real_t x = p(0);
|
||||
real_t y = p(1);
|
||||
// real_t z = (dim == 3) ? p(2) : 0.0; // Uncomment if f is changed to depend on z
|
||||
|
||||
double temp = 1 + 2*kappa*kappa;
|
||||
real_t temp = 1 + 2*kappa*kappa;
|
||||
|
||||
f(0) = temp*cos(kappa*x)*sin(kappa*y);
|
||||
f(1) = temp*cos(kappa*y)*sin(kappa*x);
|
||||
|
||||
+18
-18
@@ -45,10 +45,10 @@ using namespace mfem;
|
||||
|
||||
// Define the analytical solution and forcing terms / boundary conditions
|
||||
void uFun_ex(const Vector & x, Vector & u);
|
||||
double pFun_ex(const Vector & x);
|
||||
real_t pFun_ex(const Vector & x);
|
||||
void fFun(const Vector & x, Vector & f);
|
||||
double gFun(const Vector & x);
|
||||
double f_natural(const Vector & x);
|
||||
real_t gFun(const Vector & x);
|
||||
real_t f_natural(const Vector & x);
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
@@ -270,8 +270,8 @@ int main(int argc, char *argv[])
|
||||
// 11. Solve the linear system with MINRES.
|
||||
// Check the norm of the unpreconditioned residual.
|
||||
int maxIter(1000);
|
||||
double rtol(1.e-6);
|
||||
double atol(1.e-10);
|
||||
real_t rtol(1.e-6);
|
||||
real_t atol(1.e-10);
|
||||
|
||||
chrono.Clear();
|
||||
chrono.Start();
|
||||
@@ -313,10 +313,10 @@ int main(int argc, char *argv[])
|
||||
irs[i] = &(IntRules.Get(i, order_quad));
|
||||
}
|
||||
|
||||
double err_u = u.ComputeL2Error(ucoeff, irs);
|
||||
double norm_u = ComputeLpNorm(2., ucoeff, *mesh, irs);
|
||||
double err_p = p.ComputeL2Error(pcoeff, irs);
|
||||
double norm_p = ComputeLpNorm(2., pcoeff, *mesh, irs);
|
||||
real_t err_u = u.ComputeL2Error(ucoeff, irs);
|
||||
real_t norm_u = ComputeLpNorm(2., ucoeff, *mesh, irs);
|
||||
real_t err_p = p.ComputeL2Error(pcoeff, irs);
|
||||
real_t norm_p = ComputeLpNorm(2., pcoeff, *mesh, irs);
|
||||
|
||||
std::cout << "|| u_h - u_ex || / || u_ex || = " << err_u / norm_u << "\n";
|
||||
std::cout << "|| p_h - p_ex || / || p_ex || = " << err_p / norm_p << "\n";
|
||||
@@ -391,9 +391,9 @@ int main(int argc, char *argv[])
|
||||
|
||||
void uFun_ex(const Vector & x, Vector & u)
|
||||
{
|
||||
double xi(x(0));
|
||||
double yi(x(1));
|
||||
double zi(0.0);
|
||||
real_t xi(x(0));
|
||||
real_t yi(x(1));
|
||||
real_t zi(0.0);
|
||||
if (x.Size() == 3)
|
||||
{
|
||||
zi = x(2);
|
||||
@@ -409,11 +409,11 @@ void uFun_ex(const Vector & x, Vector & u)
|
||||
}
|
||||
|
||||
// Change if needed
|
||||
double pFun_ex(const Vector & x)
|
||||
real_t pFun_ex(const Vector & x)
|
||||
{
|
||||
double xi(x(0));
|
||||
double yi(x(1));
|
||||
double zi(0.0);
|
||||
real_t xi(x(0));
|
||||
real_t yi(x(1));
|
||||
real_t zi(0.0);
|
||||
|
||||
if (x.Size() == 3)
|
||||
{
|
||||
@@ -428,7 +428,7 @@ void fFun(const Vector & x, Vector & f)
|
||||
f = 0.0;
|
||||
}
|
||||
|
||||
double gFun(const Vector & x)
|
||||
real_t gFun(const Vector & x)
|
||||
{
|
||||
if (x.Size() == 3)
|
||||
{
|
||||
@@ -440,7 +440,7 @@ double gFun(const Vector & x)
|
||||
}
|
||||
}
|
||||
|
||||
double f_natural(const Vector & x)
|
||||
real_t f_natural(const Vector & x)
|
||||
{
|
||||
return (-pFun_ex(x));
|
||||
}
|
||||
|
||||
+18
-18
@@ -46,10 +46,10 @@ using namespace mfem;
|
||||
|
||||
// Define the analytical solution and forcing terms / boundary conditions
|
||||
void uFun_ex(const Vector & x, Vector & u);
|
||||
double pFun_ex(const Vector & x);
|
||||
real_t pFun_ex(const Vector & x);
|
||||
void fFun(const Vector & x, Vector & f);
|
||||
double gFun(const Vector & x);
|
||||
double f_natural(const Vector & x);
|
||||
real_t gFun(const Vector & x);
|
||||
real_t f_natural(const Vector & x);
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
@@ -326,8 +326,8 @@ int main(int argc, char *argv[])
|
||||
// 13. Solve the linear system with MINRES.
|
||||
// Check the norm of the unpreconditioned residual.
|
||||
int maxIter(pa ? 1000 : 500);
|
||||
double rtol(1.e-6);
|
||||
double atol(1.e-10);
|
||||
real_t rtol(1.e-6);
|
||||
real_t atol(1.e-10);
|
||||
|
||||
chrono.Clear();
|
||||
chrono.Start();
|
||||
@@ -371,10 +371,10 @@ int main(int argc, char *argv[])
|
||||
irs[i] = &(IntRules.Get(i, order_quad));
|
||||
}
|
||||
|
||||
double err_u = u->ComputeL2Error(ucoeff, irs);
|
||||
double norm_u = ComputeGlobalLpNorm(2, ucoeff, *pmesh, irs);
|
||||
double err_p = p->ComputeL2Error(pcoeff, irs);
|
||||
double norm_p = ComputeGlobalLpNorm(2, pcoeff, *pmesh, irs);
|
||||
real_t err_u = u->ComputeL2Error(ucoeff, irs);
|
||||
real_t norm_u = ComputeGlobalLpNorm(2, ucoeff, *pmesh, irs);
|
||||
real_t err_p = p->ComputeL2Error(pcoeff, irs);
|
||||
real_t norm_p = ComputeGlobalLpNorm(2, pcoeff, *pmesh, irs);
|
||||
|
||||
if (verbose)
|
||||
{
|
||||
@@ -493,9 +493,9 @@ int main(int argc, char *argv[])
|
||||
|
||||
void uFun_ex(const Vector & x, Vector & u)
|
||||
{
|
||||
double xi(x(0));
|
||||
double yi(x(1));
|
||||
double zi(0.0);
|
||||
real_t xi(x(0));
|
||||
real_t yi(x(1));
|
||||
real_t zi(0.0);
|
||||
if (x.Size() == 3)
|
||||
{
|
||||
zi = x(2);
|
||||
@@ -511,11 +511,11 @@ void uFun_ex(const Vector & x, Vector & u)
|
||||
}
|
||||
|
||||
// Change if needed
|
||||
double pFun_ex(const Vector & x)
|
||||
real_t pFun_ex(const Vector & x)
|
||||
{
|
||||
double xi(x(0));
|
||||
double yi(x(1));
|
||||
double zi(0.0);
|
||||
real_t xi(x(0));
|
||||
real_t yi(x(1));
|
||||
real_t zi(0.0);
|
||||
|
||||
if (x.Size() == 3)
|
||||
{
|
||||
@@ -530,7 +530,7 @@ void fFun(const Vector & x, Vector & f)
|
||||
f = 0.0;
|
||||
}
|
||||
|
||||
double gFun(const Vector & x)
|
||||
real_t gFun(const Vector & x)
|
||||
{
|
||||
if (x.Size() == 3)
|
||||
{
|
||||
@@ -542,7 +542,7 @@ double gFun(const Vector & x)
|
||||
}
|
||||
}
|
||||
|
||||
double f_natural(const Vector & x)
|
||||
real_t f_natural(const Vector & x)
|
||||
{
|
||||
return (-pFun_ex(x));
|
||||
}
|
||||
|
||||
+8
-8
@@ -28,8 +28,8 @@ using namespace std;
|
||||
using namespace mfem;
|
||||
|
||||
// Exact solution and r.h.s., see below for implementation.
|
||||
double analytic_solution(const Vector &x);
|
||||
double analytic_rhs(const Vector &x);
|
||||
real_t analytic_solution(const Vector &x);
|
||||
real_t analytic_rhs(const Vector &x);
|
||||
void SnapNodes(Mesh &mesh);
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
@@ -81,7 +81,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (elem_type == 0) // inscribed octahedron
|
||||
{
|
||||
const double tri_v[6][3] =
|
||||
const real_t tri_v[6][3] =
|
||||
{
|
||||
{ 1, 0, 0}, { 0, 1, 0}, {-1, 0, 0},
|
||||
{ 0, -1, 0}, { 0, 0, 1}, { 0, 0, -1}
|
||||
@@ -105,7 +105,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
else // inscribed cube
|
||||
{
|
||||
const double quad_v[8][3] =
|
||||
const real_t quad_v[8][3] =
|
||||
{
|
||||
{-1, -1, -1}, {+1, -1, -1}, {+1, +1, -1}, {-1, +1, -1},
|
||||
{-1, -1, +1}, {+1, -1, +1}, {+1, +1, +1}, {-1, +1, +1}
|
||||
@@ -249,15 +249,15 @@ int main(int argc, char *argv[])
|
||||
return 0;
|
||||
}
|
||||
|
||||
double analytic_solution(const Vector &x)
|
||||
real_t analytic_solution(const Vector &x)
|
||||
{
|
||||
double l2 = x(0)*x(0) + x(1)*x(1) + x(2)*x(2);
|
||||
real_t l2 = x(0)*x(0) + x(1)*x(1) + x(2)*x(2);
|
||||
return x(0)*x(1)/l2;
|
||||
}
|
||||
|
||||
double analytic_rhs(const Vector &x)
|
||||
real_t analytic_rhs(const Vector &x)
|
||||
{
|
||||
double l2 = x(0)*x(0) + x(1)*x(1) + x(2)*x(2);
|
||||
real_t l2 = x(0)*x(0) + x(1)*x(1) + x(2)*x(2);
|
||||
return 7*x(0)*x(1)/l2;
|
||||
}
|
||||
|
||||
|
||||
+9
-9
@@ -28,8 +28,8 @@ using namespace std;
|
||||
using namespace mfem;
|
||||
|
||||
// Exact solution and r.h.s., see below for implementation.
|
||||
double analytic_solution(const Vector &x);
|
||||
double analytic_rhs(const Vector &x);
|
||||
real_t analytic_solution(const Vector &x);
|
||||
real_t analytic_rhs(const Vector &x);
|
||||
void SnapNodes(Mesh &mesh);
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
@@ -101,7 +101,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (elem_type == 0) // inscribed octahedron
|
||||
{
|
||||
const double tri_v[6][3] =
|
||||
const real_t tri_v[6][3] =
|
||||
{
|
||||
{ 1, 0, 0}, { 0, 1, 0}, {-1, 0, 0},
|
||||
{ 0, -1, 0}, { 0, 0, 1}, { 0, 0, -1}
|
||||
@@ -125,7 +125,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
else // inscribed cube
|
||||
{
|
||||
const double quad_v[8][3] =
|
||||
const real_t quad_v[8][3] =
|
||||
{
|
||||
{-1, -1, -1}, {+1, -1, -1}, {+1, +1, -1}, {-1, +1, -1},
|
||||
{-1, -1, +1}, {+1, -1, +1}, {+1, +1, +1}, {-1, +1, +1}
|
||||
@@ -281,7 +281,7 @@ int main(int argc, char *argv[])
|
||||
delete b;
|
||||
|
||||
// 12. Compute and print the L^2 norm of the error.
|
||||
double error = x.ComputeL2Error(sol_coef);
|
||||
real_t error = x.ComputeL2Error(sol_coef);
|
||||
if (myid == 0)
|
||||
{
|
||||
cout << "\nL2 norm of error: " << error << endl;
|
||||
@@ -323,15 +323,15 @@ int main(int argc, char *argv[])
|
||||
return 0;
|
||||
}
|
||||
|
||||
double analytic_solution(const Vector &x)
|
||||
real_t analytic_solution(const Vector &x)
|
||||
{
|
||||
double l2 = x(0)*x(0) + x(1)*x(1) + x(2)*x(2);
|
||||
real_t l2 = x(0)*x(0) + x(1)*x(1) + x(2)*x(2);
|
||||
return x(0)*x(1)/l2;
|
||||
}
|
||||
|
||||
double analytic_rhs(const Vector &x)
|
||||
real_t analytic_rhs(const Vector &x)
|
||||
{
|
||||
double l2 = x(0)*x(0) + x(1)*x(1) + x(2)*x(2);
|
||||
real_t l2 = x(0)*x(0) + x(1)*x(1) + x(2)*x(2);
|
||||
return 7*x(0)*x(1)/l2;
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -206,7 +206,7 @@ int main(int argc, char *argv[])
|
||||
SparseMatrix * Shat = RAP(matBhat, matSinv, matBhat);
|
||||
|
||||
#ifndef MFEM_USE_SUITESPARSE
|
||||
const double prec_rtol = 1e-3;
|
||||
const real_t prec_rtol = 1e-3;
|
||||
const int prec_maxit = 200;
|
||||
CGSolver *S0inv = new CGSolver;
|
||||
S0inv->SetOperator(matS0);
|
||||
@@ -240,7 +240,7 @@ int main(int argc, char *argv[])
|
||||
Vector LSres(s_test);
|
||||
B.Mult(x, LSres);
|
||||
LSres -= F;
|
||||
double res = sqrt(matSinv.InnerProduct(LSres, LSres));
|
||||
real_t res = sqrt(matSinv.InnerProduct(LSres, LSres));
|
||||
cout << "\n|| B0*x0 + Bhat*xhat - F ||_{S^-1} = " << res << endl;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -283,7 +283,7 @@ int main(int argc, char *argv[])
|
||||
B.Mult(x, LSres);
|
||||
LSres -= *trueF;
|
||||
matSinv->Mult(LSres, tmp);
|
||||
double res = sqrt(InnerProduct(LSres, tmp));
|
||||
real_t res = sqrt(InnerProduct(LSres, tmp));
|
||||
if (myid == 0)
|
||||
{
|
||||
cout << "\n|| B0*x0 + Bhat*xhat - F ||_{S^-1} = " << res << endl;
|
||||
|
||||
+25
-25
@@ -58,10 +58,10 @@ int problem;
|
||||
void velocity_function(const Vector &x, Vector &v);
|
||||
|
||||
// Initial condition
|
||||
double u0_function(const Vector &x);
|
||||
real_t u0_function(const Vector &x);
|
||||
|
||||
// Inflow boundary condition
|
||||
double inflow_function(const Vector &x);
|
||||
real_t inflow_function(const Vector &x);
|
||||
|
||||
// Mesh bounding box
|
||||
Vector bb_min, bb_max;
|
||||
@@ -72,7 +72,7 @@ private:
|
||||
SparseMatrix &M, &K, A;
|
||||
GMRESSolver linear_solver;
|
||||
BlockILU prec;
|
||||
double dt;
|
||||
real_t dt;
|
||||
public:
|
||||
DG_Solver(SparseMatrix &M_, SparseMatrix &K_, const FiniteElementSpace &fes)
|
||||
: M(M_),
|
||||
@@ -89,7 +89,7 @@ public:
|
||||
linear_solver.SetPreconditioner(prec);
|
||||
}
|
||||
|
||||
void SetTimeStep(double dt_)
|
||||
void SetTimeStep(real_t dt_)
|
||||
{
|
||||
if (dt_ != dt)
|
||||
{
|
||||
@@ -135,7 +135,7 @@ public:
|
||||
FE_Evolution(BilinearForm &M_, BilinearForm &K_, const Vector &b_);
|
||||
|
||||
virtual void Mult(const Vector &x, Vector &y) const;
|
||||
virtual void ImplicitSolve(const double dt, const Vector &x, Vector &k);
|
||||
virtual void ImplicitSolve(const real_t dt, const Vector &x, Vector &k);
|
||||
|
||||
virtual ~FE_Evolution();
|
||||
};
|
||||
@@ -153,8 +153,8 @@ int main(int argc, char *argv[])
|
||||
bool fa = false;
|
||||
const char *device_config = "cpu";
|
||||
int ode_solver_type = 4;
|
||||
double t_final = 10.0;
|
||||
double dt = 0.01;
|
||||
real_t t_final = 10.0;
|
||||
real_t dt = 0.01;
|
||||
bool visualization = true;
|
||||
bool visit = false;
|
||||
bool paraview = false;
|
||||
@@ -293,7 +293,7 @@ int main(int argc, char *argv[])
|
||||
k.SetAssemblyLevel(AssemblyLevel::FULL);
|
||||
}
|
||||
m.AddDomainIntegrator(new MassIntegrator);
|
||||
constexpr double alpha = -1.0;
|
||||
constexpr real_t alpha = -1.0;
|
||||
k.AddDomainIntegrator(new ConvectionIntegrator(velocity, alpha));
|
||||
k.AddInteriorFaceIntegrator(
|
||||
new NonconservativeDGTraceIntegrator(velocity, alpha));
|
||||
@@ -393,14 +393,14 @@ int main(int argc, char *argv[])
|
||||
// iterations, ti, with a time-step dt).
|
||||
FE_Evolution adv(m, k, b);
|
||||
|
||||
double t = 0.0;
|
||||
real_t t = 0.0;
|
||||
adv.SetTime(t);
|
||||
ode_solver->Init(adv);
|
||||
|
||||
bool done = false;
|
||||
for (int ti = 0; !done; )
|
||||
{
|
||||
double dt_real = min(dt, t_final - t);
|
||||
real_t dt_real = min(dt, t_final - t);
|
||||
ode_solver->Step(u, t, dt_real);
|
||||
ti++;
|
||||
|
||||
@@ -482,7 +482,7 @@ void FE_Evolution::Mult(const Vector &x, Vector &y) const
|
||||
M_solver.Mult(z, y);
|
||||
}
|
||||
|
||||
void FE_Evolution::ImplicitSolve(const double dt, const Vector &x, Vector &k)
|
||||
void FE_Evolution::ImplicitSolve(const real_t dt, const Vector &x, Vector &k)
|
||||
{
|
||||
MFEM_VERIFY(dg_solver != NULL,
|
||||
"Implicit time integration is not supported with partial assembly");
|
||||
@@ -507,7 +507,7 @@ void velocity_function(const Vector &x, Vector &v)
|
||||
Vector X(dim);
|
||||
for (int i = 0; i < dim; i++)
|
||||
{
|
||||
double center = (bb_min[i] + bb_max[i]) * 0.5;
|
||||
real_t center = (bb_min[i] + bb_max[i]) * 0.5;
|
||||
X(i) = 2 * (x(i) - center) / (bb_max[i] - bb_min[i]);
|
||||
}
|
||||
|
||||
@@ -529,7 +529,7 @@ void velocity_function(const Vector &x, Vector &v)
|
||||
case 2:
|
||||
{
|
||||
// Clockwise rotation in 2D around the origin
|
||||
const double w = M_PI/2;
|
||||
const real_t w = M_PI/2;
|
||||
switch (dim)
|
||||
{
|
||||
case 1: v(0) = 1.0; break;
|
||||
@@ -541,8 +541,8 @@ void velocity_function(const Vector &x, Vector &v)
|
||||
case 3:
|
||||
{
|
||||
// Clockwise twisting rotation in 2D around the origin
|
||||
const double w = M_PI/2;
|
||||
double d = max((X(0)+1.)*(1.-X(0)),0.) * max((X(1)+1.)*(1.-X(1)),0.);
|
||||
const real_t w = M_PI/2;
|
||||
real_t d = max((X(0)+1.)*(1.-X(0)),0.) * max((X(1)+1.)*(1.-X(1)),0.);
|
||||
d = d*d;
|
||||
switch (dim)
|
||||
{
|
||||
@@ -556,7 +556,7 @@ void velocity_function(const Vector &x, Vector &v)
|
||||
}
|
||||
|
||||
// Initial condition
|
||||
double u0_function(const Vector &x)
|
||||
real_t u0_function(const Vector &x)
|
||||
{
|
||||
int dim = x.Size();
|
||||
|
||||
@@ -564,7 +564,7 @@ double u0_function(const Vector &x)
|
||||
Vector X(dim);
|
||||
for (int i = 0; i < dim; i++)
|
||||
{
|
||||
double center = (bb_min[i] + bb_max[i]) * 0.5;
|
||||
real_t center = (bb_min[i] + bb_max[i]) * 0.5;
|
||||
X(i) = 2 * (x(i) - center) / (bb_max[i] - bb_min[i]);
|
||||
}
|
||||
|
||||
@@ -580,28 +580,28 @@ double u0_function(const Vector &x)
|
||||
case 2:
|
||||
case 3:
|
||||
{
|
||||
double rx = 0.45, ry = 0.25, cx = 0., cy = -0.2, w = 10.;
|
||||
real_t rx = 0.45, ry = 0.25, cx = 0., cy = -0.2, w = 10.;
|
||||
if (dim == 3)
|
||||
{
|
||||
const double s = (1. + 0.25*cos(2*M_PI*X(2)));
|
||||
const real_t s = (1. + 0.25*cos(2*M_PI*X(2)));
|
||||
rx *= s;
|
||||
ry *= s;
|
||||
}
|
||||
return ( erfc(w*(X(0)-cx-rx))*erfc(-w*(X(0)-cx+rx)) *
|
||||
erfc(w*(X(1)-cy-ry))*erfc(-w*(X(1)-cy+ry)) )/16;
|
||||
return ( std::erfc(w*(X(0)-cx-rx))*std::erfc(-w*(X(0)-cx+rx)) *
|
||||
std::erfc(w*(X(1)-cy-ry))*std::erfc(-w*(X(1)-cy+ry)) )/16;
|
||||
}
|
||||
}
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
double x_ = X(0), y_ = X(1), rho, phi;
|
||||
rho = hypot(x_, y_);
|
||||
real_t x_ = X(0), y_ = X(1), rho, phi;
|
||||
rho = std::hypot(x_, y_);
|
||||
phi = atan2(y_, x_);
|
||||
return pow(sin(M_PI*rho),2)*sin(3*phi);
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
const double f = M_PI;
|
||||
const real_t f = M_PI;
|
||||
return sin(f*X(0))*sin(f*X(1));
|
||||
}
|
||||
}
|
||||
@@ -609,7 +609,7 @@ double u0_function(const Vector &x)
|
||||
}
|
||||
|
||||
// Inflow boundary condition (zero for the problems considered in this example)
|
||||
double inflow_function(const Vector &x)
|
||||
real_t inflow_function(const Vector &x)
|
||||
{
|
||||
switch (problem)
|
||||
{
|
||||
|
||||
+25
-25
@@ -59,10 +59,10 @@ int problem;
|
||||
void velocity_function(const Vector &x, Vector &v);
|
||||
|
||||
// Initial condition
|
||||
double u0_function(const Vector &x);
|
||||
real_t u0_function(const Vector &x);
|
||||
|
||||
// Inflow boundary condition
|
||||
double inflow_function(const Vector &x);
|
||||
real_t inflow_function(const Vector &x);
|
||||
|
||||
// Mesh bounding box
|
||||
Vector bb_min, bb_max;
|
||||
@@ -135,7 +135,7 @@ private:
|
||||
HypreParMatrix *A;
|
||||
GMRESSolver linear_solver;
|
||||
Solver *prec;
|
||||
double dt;
|
||||
real_t dt;
|
||||
public:
|
||||
DG_Solver(HypreParMatrix &M_, HypreParMatrix &K_, const FiniteElementSpace &fes,
|
||||
PrecType prec_type)
|
||||
@@ -169,7 +169,7 @@ public:
|
||||
M.GetDiag(M_diag);
|
||||
}
|
||||
|
||||
void SetTimeStep(double dt_)
|
||||
void SetTimeStep(real_t dt_)
|
||||
{
|
||||
if (dt_ != dt)
|
||||
{
|
||||
@@ -224,7 +224,7 @@ public:
|
||||
PrecType prec_type);
|
||||
|
||||
virtual void Mult(const Vector &x, Vector &y) const;
|
||||
virtual void ImplicitSolve(const double dt, const Vector &x, Vector &k);
|
||||
virtual void ImplicitSolve(const real_t dt, const Vector &x, Vector &k);
|
||||
|
||||
virtual ~FE_Evolution();
|
||||
};
|
||||
@@ -249,8 +249,8 @@ int main(int argc, char *argv[])
|
||||
bool fa = false;
|
||||
const char *device_config = "cpu";
|
||||
int ode_solver_type = 4;
|
||||
double t_final = 10.0;
|
||||
double dt = 0.01;
|
||||
real_t t_final = 10.0;
|
||||
real_t dt = 0.01;
|
||||
bool visualization = true;
|
||||
bool visit = false;
|
||||
bool paraview = false;
|
||||
@@ -425,7 +425,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
m->AddDomainIntegrator(new MassIntegrator);
|
||||
constexpr double alpha = -1.0;
|
||||
constexpr real_t alpha = -1.0;
|
||||
k->AddDomainIntegrator(new ConvectionIntegrator(velocity, alpha));
|
||||
k->AddInteriorFaceIntegrator(
|
||||
new NonconservativeDGTraceIntegrator(velocity, alpha));
|
||||
@@ -566,14 +566,14 @@ int main(int argc, char *argv[])
|
||||
// iterations, ti, with a time-step dt).
|
||||
FE_Evolution adv(*m, *k, *B, prec_type);
|
||||
|
||||
double t = 0.0;
|
||||
real_t t = 0.0;
|
||||
adv.SetTime(t);
|
||||
ode_solver->Init(adv);
|
||||
|
||||
bool done = false;
|
||||
for (int ti = 0; !done; )
|
||||
{
|
||||
double dt_real = min(dt, t_final - t);
|
||||
real_t dt_real = min(dt, t_final - t);
|
||||
ode_solver->Step(*U, t, dt_real);
|
||||
ti++;
|
||||
|
||||
@@ -704,7 +704,7 @@ FE_Evolution::FE_Evolution(ParBilinearForm &M_, ParBilinearForm &K_,
|
||||
// u_t = M^{-1}(Ku + b),
|
||||
// by solving associated linear system
|
||||
// (M - dt*K) d = K*u + b
|
||||
void FE_Evolution::ImplicitSolve(const double dt, const Vector &x, Vector &k)
|
||||
void FE_Evolution::ImplicitSolve(const real_t dt, const Vector &x, Vector &k)
|
||||
{
|
||||
K->Mult(x, z);
|
||||
z += b;
|
||||
@@ -736,7 +736,7 @@ void velocity_function(const Vector &x, Vector &v)
|
||||
Vector X(dim);
|
||||
for (int i = 0; i < dim; i++)
|
||||
{
|
||||
double center = (bb_min[i] + bb_max[i]) * 0.5;
|
||||
real_t center = (bb_min[i] + bb_max[i]) * 0.5;
|
||||
X(i) = 2 * (x(i) - center) / (bb_max[i] - bb_min[i]);
|
||||
}
|
||||
|
||||
@@ -758,7 +758,7 @@ void velocity_function(const Vector &x, Vector &v)
|
||||
case 2:
|
||||
{
|
||||
// Clockwise rotation in 2D around the origin
|
||||
const double w = M_PI/2;
|
||||
const real_t w = M_PI/2;
|
||||
switch (dim)
|
||||
{
|
||||
case 1: v(0) = 1.0; break;
|
||||
@@ -770,8 +770,8 @@ void velocity_function(const Vector &x, Vector &v)
|
||||
case 3:
|
||||
{
|
||||
// Clockwise twisting rotation in 2D around the origin
|
||||
const double w = M_PI/2;
|
||||
double d = max((X(0)+1.)*(1.-X(0)),0.) * max((X(1)+1.)*(1.-X(1)),0.);
|
||||
const real_t w = M_PI/2;
|
||||
real_t d = max((X(0)+1.)*(1.-X(0)),0.) * max((X(1)+1.)*(1.-X(1)),0.);
|
||||
d = d*d;
|
||||
switch (dim)
|
||||
{
|
||||
@@ -785,7 +785,7 @@ void velocity_function(const Vector &x, Vector &v)
|
||||
}
|
||||
|
||||
// Initial condition
|
||||
double u0_function(const Vector &x)
|
||||
real_t u0_function(const Vector &x)
|
||||
{
|
||||
int dim = x.Size();
|
||||
|
||||
@@ -793,7 +793,7 @@ double u0_function(const Vector &x)
|
||||
Vector X(dim);
|
||||
for (int i = 0; i < dim; i++)
|
||||
{
|
||||
double center = (bb_min[i] + bb_max[i]) * 0.5;
|
||||
real_t center = (bb_min[i] + bb_max[i]) * 0.5;
|
||||
X(i) = 2 * (x(i) - center) / (bb_max[i] - bb_min[i]);
|
||||
}
|
||||
|
||||
@@ -809,28 +809,28 @@ double u0_function(const Vector &x)
|
||||
case 2:
|
||||
case 3:
|
||||
{
|
||||
double rx = 0.45, ry = 0.25, cx = 0., cy = -0.2, w = 10.;
|
||||
real_t rx = 0.45, ry = 0.25, cx = 0., cy = -0.2, w = 10.;
|
||||
if (dim == 3)
|
||||
{
|
||||
const double s = (1. + 0.25*cos(2*M_PI*X(2)));
|
||||
const real_t s = (1. + 0.25*cos(2*M_PI*X(2)));
|
||||
rx *= s;
|
||||
ry *= s;
|
||||
}
|
||||
return ( erfc(w*(X(0)-cx-rx))*erfc(-w*(X(0)-cx+rx)) *
|
||||
erfc(w*(X(1)-cy-ry))*erfc(-w*(X(1)-cy+ry)) )/16;
|
||||
return ( std::erfc(w*(X(0)-cx-rx))*std::erfc(-w*(X(0)-cx+rx)) *
|
||||
std::erfc(w*(X(1)-cy-ry))*std::erfc(-w*(X(1)-cy+ry)) )/16;
|
||||
}
|
||||
}
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
double x_ = X(0), y_ = X(1), rho, phi;
|
||||
rho = hypot(x_, y_);
|
||||
real_t x_ = X(0), y_ = X(1), rho, phi;
|
||||
rho = std::hypot(x_, y_);
|
||||
phi = atan2(y_, x_);
|
||||
return pow(sin(M_PI*rho),2)*sin(3*phi);
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
const double f = M_PI;
|
||||
const real_t f = M_PI;
|
||||
return sin(f*X(0))*sin(f*X(1));
|
||||
}
|
||||
}
|
||||
@@ -838,7 +838,7 @@ double u0_function(const Vector &x)
|
||||
}
|
||||
|
||||
// Inflow boundary condition (zero for the problems considered in this example)
|
||||
double inflow_function(const Vector &x)
|
||||
real_t inflow_function(const Vector &x)
|
||||
{
|
||||
switch (problem)
|
||||
{
|
||||
|
||||
@@ -56,7 +56,7 @@ void BilinearForm::AllocMat()
|
||||
|
||||
int *I = dof_dof.GetI();
|
||||
int *J = dof_dof.GetJ();
|
||||
double *data = Memory<double>(I[height]);
|
||||
real_t *data = Memory<real_t>(I[height]);
|
||||
|
||||
mat = new SparseMatrix(I, J, data, height, height, true, true, true);
|
||||
*mat = 0.0;
|
||||
@@ -209,12 +209,12 @@ void BilinearForm::UseSparsity(SparseMatrix &A)
|
||||
UseSparsity(A.GetI(), A.GetJ(), A.ColumnsAreSorted());
|
||||
}
|
||||
|
||||
double& BilinearForm::Elem (int i, int j)
|
||||
real_t& BilinearForm::Elem (int i, int j)
|
||||
{
|
||||
return mat -> Elem(i,j);
|
||||
}
|
||||
|
||||
const double& BilinearForm::Elem (int i, int j) const
|
||||
const real_t& BilinearForm::Elem (int i, int j) const
|
||||
{
|
||||
return mat -> Elem(i,j);
|
||||
}
|
||||
@@ -1001,7 +1001,7 @@ void BilinearForm::EliminateEssentialBC(const Array<int> &bdr_attr_is_ess,
|
||||
}
|
||||
|
||||
void BilinearForm::EliminateEssentialBCDiag (const Array<int> &bdr_attr_is_ess,
|
||||
double value)
|
||||
real_t value)
|
||||
{
|
||||
Array<int> ess_dofs, conf_ess_dofs;
|
||||
fes->GetEssentialVDofs(bdr_attr_is_ess, ess_dofs);
|
||||
@@ -1088,7 +1088,7 @@ void BilinearForm::EliminateEssentialBCFromDofs (const Array<int> &ess_dofs,
|
||||
}
|
||||
|
||||
void BilinearForm::EliminateEssentialBCFromDofsDiag (const Array<int> &ess_dofs,
|
||||
double value)
|
||||
real_t value)
|
||||
{
|
||||
MFEM_ASSERT(ess_dofs.Size() == height,
|
||||
"incorrect dof Array size: " << ess_dofs.Size() << ' ' << height);
|
||||
@@ -1274,12 +1274,12 @@ void MixedBilinearForm::SetAssemblyLevel(AssemblyLevel assembly_level)
|
||||
}
|
||||
}
|
||||
|
||||
double & MixedBilinearForm::Elem (int i, int j)
|
||||
real_t & MixedBilinearForm::Elem (int i, int j)
|
||||
{
|
||||
return (*mat)(i, j);
|
||||
}
|
||||
|
||||
const double & MixedBilinearForm::Elem (int i, int j) const
|
||||
const real_t & MixedBilinearForm::Elem (int i, int j) const
|
||||
{
|
||||
return (*mat)(i, j);
|
||||
}
|
||||
@@ -1291,7 +1291,7 @@ void MixedBilinearForm::Mult(const Vector & x, Vector & y) const
|
||||
}
|
||||
|
||||
void MixedBilinearForm::AddMult(const Vector & x, Vector & y,
|
||||
const double a) const
|
||||
const real_t a) const
|
||||
{
|
||||
if (ext)
|
||||
{
|
||||
@@ -1310,7 +1310,7 @@ void MixedBilinearForm::MultTranspose(const Vector & x, Vector & y) const
|
||||
}
|
||||
|
||||
void MixedBilinearForm::AddMultTranspose(const Vector & x, Vector & y,
|
||||
const double a) const
|
||||
const real_t a) const
|
||||
{
|
||||
if (ext)
|
||||
{
|
||||
|
||||
+15
-15
@@ -279,13 +279,13 @@ public:
|
||||
{ return &boundary_face_integs_marker; }
|
||||
|
||||
/// Returns a reference to: \f$ M_{ij} \f$
|
||||
const double &operator()(int i, int j) { return (*mat)(i,j); }
|
||||
const real_t &operator()(int i, int j) { return (*mat)(i,j); }
|
||||
|
||||
/// Returns a reference to: \f$ M_{ij} \f$
|
||||
virtual double &Elem(int i, int j);
|
||||
virtual real_t &Elem(int i, int j);
|
||||
|
||||
/// Returns constant reference to: \f$ M_{ij} \f$
|
||||
virtual const double &Elem(int i, int j) const;
|
||||
virtual const real_t &Elem(int i, int j) const;
|
||||
|
||||
/// Matrix vector multiplication: \f$ y = M x \f$
|
||||
virtual void Mult(const Vector &x, Vector &y) const;
|
||||
@@ -297,7 +297,7 @@ public:
|
||||
{ mat->Mult(x, y); mat_e->AddMult(x, y); }
|
||||
|
||||
/// Add the matrix vector multiple to a vector: \f$ y += a M x \f$
|
||||
virtual void AddMult(const Vector &x, Vector &y, const double a = 1.0) const
|
||||
virtual void AddMult(const Vector &x, Vector &y, const real_t a = 1.0) const
|
||||
{ mat -> AddMult (x, y, a); }
|
||||
|
||||
/** @brief Add the original uneliminated matrix vector multiple to a vector.
|
||||
@@ -308,7 +308,7 @@ public:
|
||||
|
||||
/// Add the matrix transpose vector multiplication: \f$ y += a M^T x \f$
|
||||
virtual void AddMultTranspose(const Vector & x, Vector & y,
|
||||
const double a = 1.0) const
|
||||
const real_t a = 1.0) const
|
||||
{ mat->AddMultTranspose(x, y, a); }
|
||||
|
||||
/** @brief Add the original uneliminated matrix transpose vector
|
||||
@@ -321,7 +321,7 @@ public:
|
||||
virtual void MultTranspose(const Vector & x, Vector & y) const;
|
||||
|
||||
/// Compute \f$ y^T M x \f$
|
||||
double InnerProduct(const Vector &x, const Vector &y) const
|
||||
real_t InnerProduct(const Vector &x, const Vector &y) const
|
||||
{ return mat->InnerProduct (x, y); }
|
||||
|
||||
/// Returns a pointer to (approximation) of the matrix inverse: \f$ M^{-1} \f$
|
||||
@@ -423,7 +423,7 @@ public:
|
||||
Array<int> &bdr_marker);
|
||||
|
||||
/// Sets all sparse values of \f$ M \f$ and \f$ M_e \f$ to 'a'.
|
||||
void operator=(const double a)
|
||||
void operator=(const real_t a)
|
||||
{
|
||||
if (mat != NULL) { *mat = a; }
|
||||
if (mat_e != NULL) { *mat_e = a; }
|
||||
@@ -614,7 +614,7 @@ public:
|
||||
DiagonalPolicy dpolicy = DIAG_ONE);
|
||||
/// Perform elimination and set the diagonal entry to the given value
|
||||
void EliminateEssentialBCDiag(const Array<int> &bdr_attr_is_ess,
|
||||
double value);
|
||||
real_t value);
|
||||
|
||||
/// Eliminate the given @a vdofs. NOTE: here, @a vdofs is a list of DOFs.
|
||||
/** In this case the eliminations are applied to the internal \f$ M \f$
|
||||
@@ -643,7 +643,7 @@ public:
|
||||
DiagonalPolicy dpolicy = DIAG_ONE);
|
||||
/// Perform elimination and set the diagonal entry to the given value
|
||||
void EliminateEssentialBCFromDofsDiag(const Array<int> &ess_dofs,
|
||||
double value);
|
||||
real_t value);
|
||||
|
||||
/** @brief Use the stored eliminated part of the matrix (see
|
||||
EliminateVDofs(const Array<int> &, DiagonalPolicy)) to modify the r.h.s.
|
||||
@@ -652,7 +652,7 @@ public:
|
||||
Vector &b);
|
||||
|
||||
/// Compute inner product for full uneliminated matrix \f$ y^T M x + y^T M_e x \f$
|
||||
double FullInnerProduct(const Vector &x, const Vector &y) const
|
||||
real_t FullInnerProduct(const Vector &x, const Vector &y) const
|
||||
{ return mat->InnerProduct(x, y) + mat_e->InnerProduct(x, y); }
|
||||
|
||||
/// Update the @a FiniteElementSpace and delete all data associated with the old one.
|
||||
@@ -770,20 +770,20 @@ public:
|
||||
MixedBilinearForm *mbf);
|
||||
|
||||
/// Returns a reference to: \f$ M_{ij} \f$
|
||||
virtual double &Elem(int i, int j);
|
||||
virtual real_t &Elem(int i, int j);
|
||||
|
||||
/// Returns a reference to: \f$ M_{ij} \f$
|
||||
virtual const double &Elem(int i, int j) const;
|
||||
virtual const real_t &Elem(int i, int j) const;
|
||||
|
||||
/// Matrix multiplication: \f$ y = M x \f$
|
||||
virtual void Mult(const Vector & x, Vector & y) const;
|
||||
|
||||
virtual void AddMult(const Vector & x, Vector & y,
|
||||
const double a = 1.0) const;
|
||||
const real_t a = 1.0) const;
|
||||
|
||||
virtual void MultTranspose(const Vector & x, Vector & y) const;
|
||||
virtual void AddMultTranspose(const Vector & x, Vector & y,
|
||||
const double a = 1.0) const;
|
||||
const real_t a = 1.0) const;
|
||||
|
||||
virtual MatrixInverse *Inverse() const;
|
||||
|
||||
@@ -860,7 +860,7 @@ public:
|
||||
{ return &boundary_trace_face_integs_marker; }
|
||||
|
||||
/// Sets all sparse values of \f$ M \f$ to @a a.
|
||||
void operator=(const double a) { *mat = a; }
|
||||
void operator=(const real_t a) { *mat = a; }
|
||||
|
||||
/// Set the desired assembly level. The default is AssemblyLevel::LEGACY.
|
||||
/** This method must be called before assembly. */
|
||||
|
||||
+13
-13
@@ -789,7 +789,7 @@ void EABilinearFormExtension::Mult(const Vector &x, Vector &y) const
|
||||
{
|
||||
const int e = glob_j/NDOFS;
|
||||
const int j = glob_j%NDOFS;
|
||||
double res = 0.0;
|
||||
real_t res = 0.0;
|
||||
for (int i = 0; i < NDOFS; i++)
|
||||
{
|
||||
res += A(i, j, e)*X(i, e);
|
||||
@@ -824,7 +824,7 @@ void EABilinearFormExtension::Mult(const Vector &x, Vector &y) const
|
||||
{
|
||||
const int f = glob_j/NDOFS;
|
||||
const int j = glob_j%NDOFS;
|
||||
double res = 0.0;
|
||||
real_t res = 0.0;
|
||||
for (int i = 0; i < NDOFS; i++)
|
||||
{
|
||||
res += A_int(i, j, 0, f)*X(i, 0, f);
|
||||
@@ -843,7 +843,7 @@ void EABilinearFormExtension::Mult(const Vector &x, Vector &y) const
|
||||
{
|
||||
const int f = glob_j/NDOFS;
|
||||
const int j = glob_j%NDOFS;
|
||||
double res = 0.0;
|
||||
real_t res = 0.0;
|
||||
for (int i = 0; i < NDOFS; i++)
|
||||
{
|
||||
res += A_ext(i, j, 0, f)*X(i, 0, f);
|
||||
@@ -880,7 +880,7 @@ void EABilinearFormExtension::Mult(const Vector &x, Vector &y) const
|
||||
{
|
||||
const int f = glob_j/NDOFS;
|
||||
const int j = glob_j%NDOFS;
|
||||
double res = 0.0;
|
||||
real_t res = 0.0;
|
||||
for (int i = 0; i < NDOFS; i++)
|
||||
{
|
||||
res += A(i, j, f)*X(i, f);
|
||||
@@ -917,7 +917,7 @@ void EABilinearFormExtension::MultTranspose(const Vector &x, Vector &y) const
|
||||
{
|
||||
const int e = glob_j/NDOFS;
|
||||
const int j = glob_j%NDOFS;
|
||||
double res = 0.0;
|
||||
real_t res = 0.0;
|
||||
for (int i = 0; i < NDOFS; i++)
|
||||
{
|
||||
res += A(j, i, e)*X(i, e);
|
||||
@@ -952,7 +952,7 @@ void EABilinearFormExtension::MultTranspose(const Vector &x, Vector &y) const
|
||||
{
|
||||
const int f = glob_j/NDOFS;
|
||||
const int j = glob_j%NDOFS;
|
||||
double res = 0.0;
|
||||
real_t res = 0.0;
|
||||
for (int i = 0; i < NDOFS; i++)
|
||||
{
|
||||
res += A_int(j, i, 0, f)*X(i, 0, f);
|
||||
@@ -971,7 +971,7 @@ void EABilinearFormExtension::MultTranspose(const Vector &x, Vector &y) const
|
||||
{
|
||||
const int f = glob_j/NDOFS;
|
||||
const int j = glob_j%NDOFS;
|
||||
double res = 0.0;
|
||||
real_t res = 0.0;
|
||||
for (int i = 0; i < NDOFS; i++)
|
||||
{
|
||||
res += A_ext(j, i, 1, f)*X(i, 0, f);
|
||||
@@ -1008,7 +1008,7 @@ void EABilinearFormExtension::MultTranspose(const Vector &x, Vector &y) const
|
||||
{
|
||||
const int f = glob_j/NDOFS;
|
||||
const int j = glob_j%NDOFS;
|
||||
double res = 0.0;
|
||||
real_t res = 0.0;
|
||||
for (int i = 0; i < NDOFS; i++)
|
||||
{
|
||||
res += A(j, i, f)*X(i, f);
|
||||
@@ -1436,7 +1436,7 @@ void PAMixedBilinearFormExtension::SetupMultInputs(
|
||||
const Operator *elem_restrict_y,
|
||||
Vector &y,
|
||||
Vector &localY,
|
||||
const double c) const
|
||||
const real_t c) const
|
||||
{
|
||||
// * G operation: localX = c*local(x)
|
||||
if (elem_restrict_x)
|
||||
@@ -1476,7 +1476,7 @@ void PAMixedBilinearFormExtension::Mult(const Vector &x, Vector &y) const
|
||||
}
|
||||
|
||||
void PAMixedBilinearFormExtension::AddMult(const Vector &x, Vector &y,
|
||||
const double c) const
|
||||
const real_t c) const
|
||||
{
|
||||
Array<BilinearFormIntegrator*> &integrators = *a->GetDBFI();
|
||||
const int iSz = integrators.Size();
|
||||
@@ -1508,7 +1508,7 @@ void PAMixedBilinearFormExtension::MultTranspose(const Vector &x,
|
||||
}
|
||||
|
||||
void PAMixedBilinearFormExtension::AddMultTranspose(const Vector &x, Vector &y,
|
||||
const double c) const
|
||||
const real_t c) const
|
||||
{
|
||||
Array<BilinearFormIntegrator*> &integrators = *a->GetDBFI();
|
||||
const int iSz = integrators.Size();
|
||||
@@ -1642,7 +1642,7 @@ void PADiscreteLinearOperatorExtension::Assemble()
|
||||
}
|
||||
|
||||
void PADiscreteLinearOperatorExtension::AddMult(
|
||||
const Vector &x, Vector &y, const double c) const
|
||||
const Vector &x, Vector &y, const real_t c) const
|
||||
{
|
||||
Array<BilinearFormIntegrator*> &integrators = *a->GetDBFI();
|
||||
const int iSz = integrators.Size();
|
||||
@@ -1675,7 +1675,7 @@ void PADiscreteLinearOperatorExtension::AddMult(
|
||||
}
|
||||
|
||||
void PADiscreteLinearOperatorExtension::AddMultTranspose(
|
||||
const Vector &x, Vector &y, const double c) const
|
||||
const Vector &x, Vector &y, const real_t c) const
|
||||
{
|
||||
Array<BilinearFormIntegrator*> &integrators = *a->GetDBFI();
|
||||
const int iSz = integrators.Size();
|
||||
|
||||
@@ -248,7 +248,7 @@ protected:
|
||||
void SetupMultInputs(const Operator *elem_restrict_x,
|
||||
const Vector &x, Vector &localX,
|
||||
const Operator *elem_restrict_y,
|
||||
Vector &y, Vector &localY, const double c) const;
|
||||
Vector &y, Vector &localY, const real_t c) const;
|
||||
|
||||
public:
|
||||
PAMixedBilinearFormExtension(MixedBilinearForm *form);
|
||||
@@ -277,11 +277,11 @@ public:
|
||||
/// y = A*x
|
||||
void Mult(const Vector &x, Vector &y) const;
|
||||
/// y += c*A*x
|
||||
void AddMult(const Vector &x, Vector &y, const double c=1.0) const;
|
||||
void AddMult(const Vector &x, Vector &y, const real_t c=1.0) const;
|
||||
/// y = A^T*x
|
||||
void MultTranspose(const Vector &x, Vector &y) const;
|
||||
/// y += c*A^T*x
|
||||
void AddMultTranspose(const Vector &x, Vector &y, const double c=1.0) const;
|
||||
void AddMultTranspose(const Vector &x, Vector &y, const real_t c=1.0) const;
|
||||
/// Assemble the diagonal of ADA^T for a diagonal vector D.
|
||||
void AssembleDiagonal_ADAt(const Vector &D, Vector &diag) const;
|
||||
|
||||
@@ -305,9 +305,9 @@ public:
|
||||
/// Partial assembly of all internal integrators
|
||||
void Assemble();
|
||||
|
||||
void AddMult(const Vector &x, Vector &y, const double c=1.0) const;
|
||||
void AddMult(const Vector &x, Vector &y, const real_t c=1.0) const;
|
||||
|
||||
void AddMultTranspose(const Vector &x, Vector &y, const double c=1.0) const;
|
||||
void AddMultTranspose(const Vector &x, Vector &y, const real_t c=1.0) const;
|
||||
|
||||
void FormRectangularSystemOperator(const Array<int>&, const Array<int>&,
|
||||
OperatorHandle& A);
|
||||
|
||||
+90
-90
@@ -498,7 +498,7 @@ void MixedScalarIntegrator::AssembleElementMatrix2(
|
||||
this->CalcTestShape(test_fe, Trans, test_shape);
|
||||
this->CalcTrialShape(trial_fe, Trans, trial_shape);
|
||||
|
||||
double w = Trans.Weight() * ip.weight;
|
||||
real_t w = Trans.Weight() * ip.weight;
|
||||
|
||||
if (Q)
|
||||
{
|
||||
@@ -592,7 +592,7 @@ void MixedVectorIntegrator::AssembleElementMatrix2(
|
||||
this->CalcTrialShape(trial_fe, Trans, trial_shape);
|
||||
}
|
||||
|
||||
double w = Trans.Weight() * ip.weight;
|
||||
real_t w = Trans.Weight() * ip.weight;
|
||||
|
||||
if (MQ)
|
||||
{
|
||||
@@ -706,7 +706,7 @@ void MixedScalarVectorIntegrator::AssembleElementMatrix2(
|
||||
int sca_nd = sca_fe->GetDof();
|
||||
int vec_nd = vec_fe->GetDof();
|
||||
int vdim = GetVDim(*vec_fe);
|
||||
double vtmp;
|
||||
real_t vtmp;
|
||||
|
||||
MFEM_VERIFY(VQ->GetVDim() == vdim, "MixedScalarVectorIntegrator: "
|
||||
"Dimensions of VectorCoefficient and Vector-valued basis "
|
||||
@@ -745,7 +745,7 @@ void MixedScalarVectorIntegrator::AssembleElementMatrix2(
|
||||
this->CalcShape(*sca_fe, Trans, shape);
|
||||
this->CalcVShape(*vec_fe, Trans, vshape);
|
||||
|
||||
double w = Trans.Weight() * ip.weight;
|
||||
real_t w = Trans.Weight() * ip.weight;
|
||||
|
||||
VQ->Eval(V, Trans, ip);
|
||||
V *= w;
|
||||
@@ -770,7 +770,7 @@ void GradientIntegrator::AssembleElementMatrix2(
|
||||
dim = test_fe.GetDim();
|
||||
int trial_dof = trial_fe.GetDof();
|
||||
int test_dof = test_fe.GetDof();
|
||||
double c;
|
||||
real_t c;
|
||||
Vector d_col;
|
||||
|
||||
dshape.SetSize(trial_dof, dim);
|
||||
@@ -837,7 +837,7 @@ void DiffusionIntegrator::AssembleElementMatrix
|
||||
dim = el.GetDim();
|
||||
int spaceDim = Trans.GetSpaceDim();
|
||||
bool square = (dim == spaceDim);
|
||||
double w;
|
||||
real_t w;
|
||||
|
||||
if (VQ)
|
||||
{
|
||||
@@ -931,7 +931,7 @@ void DiffusionIntegrator::AssembleElementMatrix2(
|
||||
dim = trial_fe.GetDim();
|
||||
int spaceDim = Trans.GetSpaceDim();
|
||||
bool square = (dim == spaceDim);
|
||||
double w;
|
||||
real_t w;
|
||||
|
||||
if (VQ)
|
||||
{
|
||||
@@ -1013,7 +1013,7 @@ void DiffusionIntegrator::AssembleElementVector(
|
||||
int nd = el.GetDof();
|
||||
dim = el.GetDim();
|
||||
int spaceDim = Tr.GetSpaceDim();
|
||||
double w;
|
||||
real_t w;
|
||||
|
||||
if (VQ)
|
||||
{
|
||||
@@ -1187,7 +1187,7 @@ void DiffusionIntegrator::ComputeElementFlux
|
||||
}
|
||||
}
|
||||
|
||||
double DiffusionIntegrator::ComputeFluxEnergy
|
||||
real_t DiffusionIntegrator::ComputeFluxEnergy
|
||||
( const FiniteElement &fluxelem, ElementTransformation &Trans,
|
||||
Vector &flux, Vector* d_energy)
|
||||
{
|
||||
@@ -1210,7 +1210,7 @@ double DiffusionIntegrator::ComputeFluxEnergy
|
||||
int order = 2 * fluxelem.GetOrder(); // <--
|
||||
const IntegrationRule *ir = &IntRules.Get(fluxelem.GetGeomType(), order);
|
||||
|
||||
double energy = 0.0;
|
||||
real_t energy = 0.0;
|
||||
if (d_energy) { *d_energy = 0.0; }
|
||||
|
||||
for (int i = 0; i < ir->GetNPoints(); i++)
|
||||
@@ -1228,7 +1228,7 @@ double DiffusionIntegrator::ComputeFluxEnergy
|
||||
}
|
||||
|
||||
Trans.SetIntPoint(&ip);
|
||||
double w = Trans.Weight() * ip.weight;
|
||||
real_t w = Trans.Weight() * ip.weight;
|
||||
|
||||
if (MQ)
|
||||
{
|
||||
@@ -1243,7 +1243,7 @@ double DiffusionIntegrator::ComputeFluxEnergy
|
||||
}
|
||||
else
|
||||
{
|
||||
double e = (pointflux * pointflux);
|
||||
real_t e = (pointflux * pointflux);
|
||||
if (Q) { e *= Q->Eval(Trans, ip); }
|
||||
energy += w * e;
|
||||
}
|
||||
@@ -1291,7 +1291,7 @@ void MassIntegrator::AssembleElementMatrix
|
||||
{
|
||||
int nd = el.GetDof();
|
||||
// int dim = el.GetDim();
|
||||
double w;
|
||||
real_t w;
|
||||
|
||||
#ifdef MFEM_THREAD_SAFE
|
||||
Vector shape;
|
||||
@@ -1325,7 +1325,7 @@ void MassIntegrator::AssembleElementMatrix2(
|
||||
{
|
||||
int tr_nd = trial_fe.GetDof();
|
||||
int te_nd = test_fe.GetDof();
|
||||
double w;
|
||||
real_t w;
|
||||
|
||||
#ifdef MFEM_THREAD_SAFE
|
||||
Vector shape, te_shape;
|
||||
@@ -1380,7 +1380,7 @@ void BoundaryMassIntegrator::AssembleFaceMatrix(
|
||||
"support for interior faces is not implemented");
|
||||
|
||||
int nd1 = el1.GetDof();
|
||||
double w;
|
||||
real_t w;
|
||||
|
||||
#ifdef MFEM_THREAD_SAFE
|
||||
Vector shape;
|
||||
@@ -1499,15 +1499,15 @@ void GroupConvectionIntegrator::AssembleElementMatrix(
|
||||
|
||||
Mult(dshape, adjJ, grad);
|
||||
|
||||
double w = alpha * ip.weight;
|
||||
real_t w = alpha * ip.weight;
|
||||
|
||||
// elmat(k,l) += \sum_s w*shape(k)*Q_nodal(s,k)*grad(l,s)
|
||||
for (int k = 0; k < nd; k++)
|
||||
{
|
||||
double wsk = w*shape(k);
|
||||
real_t wsk = w*shape(k);
|
||||
for (int l = 0; l < nd; l++)
|
||||
{
|
||||
double a = 0.0;
|
||||
real_t a = 0.0;
|
||||
for (int s = 0; s < dim; s++)
|
||||
{
|
||||
a += Q_nodal(s,k)*grad(l,s);
|
||||
@@ -1540,7 +1540,7 @@ void VectorMassIntegrator::AssembleElementMatrix
|
||||
int nd = el.GetDof();
|
||||
int spaceDim = Trans.GetSpaceDim();
|
||||
|
||||
double norm;
|
||||
real_t norm;
|
||||
|
||||
// If vdim is not set, set it to the space dimension
|
||||
vdim = (vdim == -1) ? spaceDim : vdim;
|
||||
@@ -1622,7 +1622,7 @@ void VectorMassIntegrator::AssembleElementMatrix2(
|
||||
int tr_nd = trial_fe.GetDof();
|
||||
int te_nd = test_fe.GetDof();
|
||||
|
||||
double norm;
|
||||
real_t norm;
|
||||
|
||||
// If vdim is not set, set it to the space dimension
|
||||
vdim = (vdim == -1) ? Trans.GetSpaceDim() : vdim;
|
||||
@@ -1729,7 +1729,7 @@ void VectorFEDivergenceIntegrator::AssembleElementMatrix2(
|
||||
trial_fe.CalcDivShape(ip, divshape);
|
||||
Trans.SetIntPoint(&ip);
|
||||
test_fe.CalcPhysShape(Trans, shape);
|
||||
double w = ip.weight;
|
||||
real_t w = ip.weight;
|
||||
if (Q)
|
||||
{
|
||||
Trans.SetIntPoint(&ip);
|
||||
@@ -1810,7 +1810,7 @@ void VectorFEWeakDivergenceIntegrator::AssembleElementMatrix2(
|
||||
|
||||
trial_fe.CalcVShape(Trans, vshape);
|
||||
|
||||
double w = ip.weight;
|
||||
real_t w = ip.weight;
|
||||
|
||||
if (Q)
|
||||
{
|
||||
@@ -1900,7 +1900,7 @@ void VectorFECurlIntegrator::AssembleElementMatrix2(
|
||||
}
|
||||
}
|
||||
|
||||
double w = ip.weight;
|
||||
real_t w = ip.weight;
|
||||
|
||||
if (Q)
|
||||
{
|
||||
@@ -1931,7 +1931,7 @@ void DerivativeIntegrator::AssembleElementMatrix2 (
|
||||
int spaceDim = Trans.GetSpaceDim();
|
||||
|
||||
int i, l;
|
||||
double det;
|
||||
real_t det;
|
||||
|
||||
elmat.SetSize (test_nd,trial_nd);
|
||||
dshape.SetSize (trial_nd,dim);
|
||||
@@ -1994,7 +1994,7 @@ void CurlCurlIntegrator::AssembleElementMatrix
|
||||
int nd = el.GetDof();
|
||||
dim = el.GetDim();
|
||||
int dimc = el.GetCurlDim();
|
||||
double w;
|
||||
real_t w;
|
||||
|
||||
#ifdef MFEM_THREAD_SAFE
|
||||
Vector D;
|
||||
@@ -2067,7 +2067,7 @@ void CurlCurlIntegrator::AssembleElementMatrix2(const FiniteElement &trial_fe,
|
||||
int te_nd = test_fe.GetDof();
|
||||
dim = trial_fe.GetDim();
|
||||
int dimc = trial_fe.GetCurlDim();
|
||||
double w;
|
||||
real_t w;
|
||||
|
||||
#ifdef MFEM_THREAD_SAFE
|
||||
Vector D;
|
||||
@@ -2154,7 +2154,7 @@ void CurlCurlIntegrator
|
||||
// TODO: Q, wcoef?
|
||||
}
|
||||
|
||||
double CurlCurlIntegrator::ComputeFluxEnergy(const FiniteElement &fluxelem,
|
||||
real_t CurlCurlIntegrator::ComputeFluxEnergy(const FiniteElement &fluxelem,
|
||||
ElementTransformation &Trans,
|
||||
Vector &flux, Vector *d_energy)
|
||||
{
|
||||
@@ -2171,7 +2171,7 @@ double CurlCurlIntegrator::ComputeFluxEnergy(const FiniteElement &fluxelem,
|
||||
int order = 2 * fluxelem.GetOrder(); // <--
|
||||
const IntegrationRule &ir = IntRules.Get(fluxelem.GetGeomType(), order);
|
||||
|
||||
double energy = 0.0;
|
||||
real_t energy = 0.0;
|
||||
if (d_energy) { *d_energy = 0.0; }
|
||||
|
||||
Vector* pfluxes = NULL;
|
||||
@@ -2189,9 +2189,9 @@ double CurlCurlIntegrator::ComputeFluxEnergy(const FiniteElement &fluxelem,
|
||||
// fluxelem.CalcVShape(ip, vshape);
|
||||
vshape.MultTranspose(flux, pointflux);
|
||||
|
||||
double w = Trans.Weight() * ip.weight;
|
||||
real_t w = Trans.Weight() * ip.weight;
|
||||
|
||||
double e = w * (pointflux * pointflux);
|
||||
real_t e = w * (pointflux * pointflux);
|
||||
|
||||
if (Q)
|
||||
{
|
||||
@@ -2293,7 +2293,7 @@ void VectorCurlCurlIntegrator::AssembleElementMatrix(
|
||||
|
||||
Trans.SetIntPoint(&ip);
|
||||
CalcAdjugate(Trans.Jacobian(), Jadj);
|
||||
double w = ip.weight / Trans.Weight();
|
||||
real_t w = ip.weight / Trans.Weight();
|
||||
|
||||
Mult(dshape_hat, Jadj, dshape);
|
||||
dshape.GradToCurl(curlshape);
|
||||
@@ -2307,7 +2307,7 @@ void VectorCurlCurlIntegrator::AssembleElementMatrix(
|
||||
}
|
||||
}
|
||||
|
||||
double VectorCurlCurlIntegrator::GetElementEnergy(
|
||||
real_t VectorCurlCurlIntegrator::GetElementEnergy(
|
||||
const FiniteElement &el, ElementTransformation &Tr, const Vector &elfun)
|
||||
{
|
||||
int dim = el.GetDim();
|
||||
@@ -2332,7 +2332,7 @@ double VectorCurlCurlIntegrator::GetElementEnergy(
|
||||
ir = &IntRules.Get(el.GetGeomType(), order);
|
||||
}
|
||||
|
||||
double energy = 0.;
|
||||
real_t energy = 0.;
|
||||
for (int i = 0; i < ir->GetNPoints(); i++)
|
||||
{
|
||||
const IntegrationPoint &ip = ir->IntPoint(i);
|
||||
@@ -2342,20 +2342,20 @@ double VectorCurlCurlIntegrator::GetElementEnergy(
|
||||
|
||||
Tr.SetIntPoint(&ip);
|
||||
CalcAdjugate(Tr.Jacobian(), Jadj);
|
||||
double w = ip.weight / Tr.Weight();
|
||||
real_t w = ip.weight / Tr.Weight();
|
||||
|
||||
Mult(grad_hat, Jadj, grad);
|
||||
|
||||
if (dim == 2)
|
||||
{
|
||||
double curl = grad(0,1) - grad(1,0);
|
||||
real_t curl = grad(0,1) - grad(1,0);
|
||||
w *= curl * curl;
|
||||
}
|
||||
else
|
||||
{
|
||||
double curl_x = grad(2,1) - grad(1,2);
|
||||
double curl_y = grad(0,2) - grad(2,0);
|
||||
double curl_z = grad(1,0) - grad(0,1);
|
||||
real_t curl_x = grad(2,1) - grad(1,2);
|
||||
real_t curl_y = grad(0,2) - grad(2,0);
|
||||
real_t curl_z = grad(1,0) - grad(0,1);
|
||||
w *= curl_x * curl_x + curl_y * curl_y + curl_z * curl_z;
|
||||
}
|
||||
|
||||
@@ -2405,7 +2405,7 @@ void MixedCurlIntegrator::AssembleElementMatrix2(
|
||||
shape.SetSize(test_dof);
|
||||
elmat = 0.0;
|
||||
|
||||
double c;
|
||||
real_t c;
|
||||
Vector d_col;
|
||||
const IntegrationRule *ir = IntRule;
|
||||
|
||||
@@ -2438,7 +2438,7 @@ void MixedCurlIntegrator::AssembleElementMatrix2(
|
||||
|
||||
for (int d = 0; d < dimc; ++d)
|
||||
{
|
||||
double * curldata = &(curlshape.GetData())[d*trial_dof];
|
||||
real_t * curldata = &(curlshape.GetData())[d*trial_dof];
|
||||
for (int jj = 0; jj < trial_dof; ++jj)
|
||||
{
|
||||
for (int ii = 0; ii < test_dof; ++ii)
|
||||
@@ -2460,7 +2460,7 @@ void VectorFEMassIntegrator::AssembleElementMatrix(
|
||||
int spaceDim = Trans.GetSpaceDim();
|
||||
int vdim = std::max(spaceDim, el.GetRangeDim());
|
||||
|
||||
double w;
|
||||
real_t w;
|
||||
|
||||
#ifdef MFEM_THREAD_SAFE
|
||||
Vector D(DQ ? DQ->GetVDim() : 0);
|
||||
@@ -2529,7 +2529,7 @@ void VectorFEMassIntegrator::AssembleElementMatrix2(
|
||||
int vdim = std::max(spaceDim, trial_fe.GetRangeDim());
|
||||
int trial_dof = trial_fe.GetDof();
|
||||
int test_dof = test_fe.GetDof();
|
||||
double w;
|
||||
real_t w;
|
||||
|
||||
#ifdef MFEM_THREAD_SAFE
|
||||
DenseMatrix trial_vshape(trial_dof, spaceDim);
|
||||
@@ -2589,7 +2589,7 @@ void VectorFEMassIntegrator::AssembleElementMatrix2(
|
||||
{
|
||||
for (int k = 0; k < trial_dof; k++)
|
||||
{
|
||||
double Kv = 0.0;
|
||||
real_t Kv = 0.0;
|
||||
for (int vd = 0; vd < spaceDim; vd++)
|
||||
{
|
||||
Kv += K(d, vd) * trial_vshape(k, vd);
|
||||
@@ -2628,7 +2628,7 @@ void VectorFEMassIntegrator::AssembleElementMatrix2(
|
||||
int test_vdim = std::max(spaceDim, test_fe.GetRangeDim());
|
||||
int trial_dof = trial_fe.GetDof();
|
||||
int test_dof = test_fe.GetDof();
|
||||
double w;
|
||||
real_t w;
|
||||
|
||||
#ifdef MFEM_THREAD_SAFE
|
||||
DenseMatrix trial_vshape(trial_dof,trial_vdim);
|
||||
@@ -2702,7 +2702,7 @@ void VectorDivergenceIntegrator::AssembleElementMatrix2(
|
||||
dim = trial_fe.GetDim();
|
||||
int trial_dof = trial_fe.GetDof();
|
||||
int test_dof = test_fe.GetDof();
|
||||
double c;
|
||||
real_t c;
|
||||
|
||||
dshape.SetSize (trial_dof, dim);
|
||||
gshape.SetSize (trial_dof, dim);
|
||||
@@ -2759,7 +2759,7 @@ void DivDivIntegrator::AssembleElementMatrix(
|
||||
DenseMatrix &elmat)
|
||||
{
|
||||
int dof = el.GetDof();
|
||||
double c;
|
||||
real_t c;
|
||||
|
||||
#ifdef MFEM_THREAD_SAFE
|
||||
Vector divshape(dof);
|
||||
@@ -2804,7 +2804,7 @@ void DivDivIntegrator::AssembleElementMatrix2(
|
||||
{
|
||||
int tr_nd = trial_fe.GetDof();
|
||||
int te_nd = test_fe.GetDof();
|
||||
double c;
|
||||
real_t c;
|
||||
|
||||
#ifdef MFEM_THREAD_SAFE
|
||||
Vector divshape(tr_nd);
|
||||
@@ -2888,7 +2888,7 @@ void VectorDiffusionIntegrator::AssembleElementMatrix(
|
||||
el.CalcDShape(ip, dshape);
|
||||
|
||||
Trans.SetIntPoint(&ip);
|
||||
double w = Trans.Weight();
|
||||
real_t w = Trans.Weight();
|
||||
w = ip.weight / (square ? w : w*w*w);
|
||||
// AdjugateJacobian = / adj(J), if J is square
|
||||
// \ adj(J^t.J).J^t, otherwise
|
||||
@@ -2973,7 +2973,7 @@ void VectorDiffusionIntegrator::AssembleElementVector(
|
||||
el.CalcDShape(ip, dshape);
|
||||
|
||||
Tr.SetIntPoint(&ip);
|
||||
double w = Tr.Weight();
|
||||
real_t w = Tr.Weight();
|
||||
w = ip.weight / (square ? w : w*w*w);
|
||||
Mult(dshape, Tr.AdjugateJacobian(), dshapedxt);
|
||||
MultAAt(dshapedxt, pelmat);
|
||||
@@ -3029,7 +3029,7 @@ void ElasticityIntegrator::AssembleElementMatrix(
|
||||
{
|
||||
int dof = el.GetDof();
|
||||
int dim = el.GetDim();
|
||||
double w, L, M;
|
||||
real_t w, L, M;
|
||||
|
||||
MFEM_ASSERT(dim == Trans.GetSpaceDim(), "");
|
||||
|
||||
@@ -3114,7 +3114,7 @@ void ElasticityIntegrator::ComputeElementFlux(
|
||||
const int dof = el.GetDof();
|
||||
const int dim = el.GetDim();
|
||||
const int tdim = dim*(dim+1)/2; // num. entries in a symmetric tensor
|
||||
double L, M;
|
||||
real_t L, M;
|
||||
|
||||
MFEM_ASSERT(dim == 2 || dim == 3,
|
||||
"dimension is not supported: dim = " << dim);
|
||||
@@ -3128,7 +3128,7 @@ void ElasticityIntegrator::ComputeElementFlux(
|
||||
dshape.SetSize(dof, dim);
|
||||
#endif
|
||||
|
||||
double gh_data[9], grad_data[9];
|
||||
real_t gh_data[9], grad_data[9];
|
||||
DenseMatrix gh(gh_data, dim, dim);
|
||||
DenseMatrix grad(grad_data, dim, dim);
|
||||
|
||||
@@ -3162,7 +3162,7 @@ void ElasticityIntegrator::ComputeElementFlux(
|
||||
|
||||
// stress = 2*M*e(u) + L*tr(e(u))*I, where
|
||||
// e(u) = (1/2)*(grad(u) + grad(u)^T)
|
||||
const double M2 = 2.0*M;
|
||||
const real_t M2 = 2.0*M;
|
||||
if (dim == 2)
|
||||
{
|
||||
L *= (grad(0,0) + grad(1,1));
|
||||
@@ -3185,14 +3185,14 @@ void ElasticityIntegrator::ComputeElementFlux(
|
||||
}
|
||||
}
|
||||
|
||||
double ElasticityIntegrator::ComputeFluxEnergy(const FiniteElement &fluxelem,
|
||||
real_t ElasticityIntegrator::ComputeFluxEnergy(const FiniteElement &fluxelem,
|
||||
ElementTransformation &Trans,
|
||||
Vector &flux, Vector *d_energy)
|
||||
{
|
||||
const int dof = fluxelem.GetDof();
|
||||
const int dim = fluxelem.GetDim();
|
||||
const int tdim = dim*(dim+1)/2; // num. entries in a symmetric tensor
|
||||
double L, M;
|
||||
real_t L, M;
|
||||
|
||||
// The MFEM_ASSERT constraints in ElasticityIntegrator::ComputeElementFlux
|
||||
// are assumed here too.
|
||||
@@ -3204,7 +3204,7 @@ double ElasticityIntegrator::ComputeFluxEnergy(const FiniteElement &fluxelem,
|
||||
#else
|
||||
Vector shape(dof);
|
||||
#endif
|
||||
double pointstress_data[6];
|
||||
real_t pointstress_data[6];
|
||||
Vector pointstress(pointstress_data, tdim);
|
||||
|
||||
// View of the 'flux' vector as a (dof x tdim) matrix
|
||||
@@ -3220,7 +3220,7 @@ double ElasticityIntegrator::ComputeFluxEnergy(const FiniteElement &fluxelem,
|
||||
ir = &IntRules.Get(fluxelem.GetGeomType(), order);
|
||||
}
|
||||
|
||||
double energy = 0.0;
|
||||
real_t energy = 0.0;
|
||||
|
||||
for (int i = 0; i < ir->GetNPoints(); i++)
|
||||
{
|
||||
@@ -3230,7 +3230,7 @@ double ElasticityIntegrator::ComputeFluxEnergy(const FiniteElement &fluxelem,
|
||||
flux_mat.MultTranspose(shape, pointstress);
|
||||
|
||||
Trans.SetIntPoint(&ip);
|
||||
double w = Trans.Weight() * ip.weight;
|
||||
real_t w = Trans.Weight() * ip.weight;
|
||||
|
||||
M = mu->Eval(Trans, ip);
|
||||
if (lambda)
|
||||
@@ -3254,19 +3254,19 @@ double ElasticityIntegrator::ComputeFluxEnergy(const FiniteElement &fluxelem,
|
||||
// Then from the first identity above we can find the strain:
|
||||
// e = (1/(2*mu))*(s - lambda*tr(e)*I)
|
||||
|
||||
double pt_e; // point strain energy density
|
||||
const double *s = pointstress_data;
|
||||
real_t pt_e; // point strain energy density
|
||||
const real_t *s = pointstress_data;
|
||||
if (dim == 2)
|
||||
{
|
||||
// s entries: s_xx, s_yy, s_xy
|
||||
const double tr_e = (s[0] + s[1])/(2*(M + L));
|
||||
const real_t tr_e = (s[0] + s[1])/(2*(M + L));
|
||||
L *= tr_e;
|
||||
pt_e = (0.25/M)*(s[0]*(s[0] - L) + s[1]*(s[1] - L) + 2*s[2]*s[2]);
|
||||
}
|
||||
else // (dim == 3)
|
||||
{
|
||||
// s entries: s_xx, s_yy, s_zz, s_xy, s_xz, s_yz
|
||||
const double tr_e = (s[0] + s[1] + s[2])/(2*M + 3*L);
|
||||
const real_t tr_e = (s[0] + s[1] + s[2])/(2*M + 3*L);
|
||||
L *= tr_e;
|
||||
pt_e = (0.25/M)*(s[0]*(s[0] - L) + s[1]*(s[1] - L) + s[2]*(s[2] - L) +
|
||||
2*(s[3]*s[3] + s[4]*s[4] + s[5]*s[5]));
|
||||
@@ -3285,7 +3285,7 @@ void DGTraceIntegrator::AssembleFaceMatrix(const FiniteElement &el1,
|
||||
{
|
||||
int ndof1, ndof2;
|
||||
|
||||
double un, a, b, w;
|
||||
real_t un, a, b, w;
|
||||
|
||||
dim = el1.GetDim();
|
||||
ndof1 = el1.GetDof();
|
||||
@@ -3358,7 +3358,7 @@ void DGTraceIntegrator::AssembleFaceMatrix(const FiniteElement &el1,
|
||||
|
||||
if (rho)
|
||||
{
|
||||
double rho_p;
|
||||
real_t rho_p;
|
||||
if (un >= 0.0 && ndof2)
|
||||
{
|
||||
rho_p = rho->Eval(*Trans.Elem2, eip2);
|
||||
@@ -3425,7 +3425,7 @@ void DGDiffusionIntegrator::AssembleFaceMatrix(
|
||||
{
|
||||
int dim, ndof1, ndof2, ndofs;
|
||||
bool kappa_is_nonzero = (kappa != 0.);
|
||||
double w, wq = 0.0;
|
||||
real_t w, wq = 0.0;
|
||||
|
||||
dim = el1.GetDim();
|
||||
ndof1 = el1.GetDof();
|
||||
@@ -3600,7 +3600,7 @@ void DGDiffusionIntegrator::AssembleFaceMatrix(
|
||||
wq *= kappa;
|
||||
for (int i = 0; i < ndof1; i++)
|
||||
{
|
||||
const double wsi = wq*shape1(i);
|
||||
const real_t wsi = wq*shape1(i);
|
||||
for (int j = 0; j <= i; j++)
|
||||
{
|
||||
jmat(i, j) += wsi * shape1(j);
|
||||
@@ -3611,7 +3611,7 @@ void DGDiffusionIntegrator::AssembleFaceMatrix(
|
||||
for (int i = 0; i < ndof2; i++)
|
||||
{
|
||||
const int i2 = ndof1 + i;
|
||||
const double wsi = wq*shape2(i);
|
||||
const real_t wsi = wq*shape2(i);
|
||||
for (int j = 0; j < ndof1; j++)
|
||||
{
|
||||
jmat(i2, j) -= wsi * shape1(j);
|
||||
@@ -3632,7 +3632,7 @@ void DGDiffusionIntegrator::AssembleFaceMatrix(
|
||||
{
|
||||
for (int j = 0; j < i; j++)
|
||||
{
|
||||
double aij = elmat(i,j), aji = elmat(j,i), mij = jmat(i,j);
|
||||
real_t aij = elmat(i,j), aji = elmat(j,i), mij = jmat(i,j);
|
||||
elmat(i,j) = sigma*aji - aij + mij;
|
||||
elmat(j,i) = sigma*aij - aji + mij;
|
||||
}
|
||||
@@ -3645,7 +3645,7 @@ void DGDiffusionIntegrator::AssembleFaceMatrix(
|
||||
{
|
||||
for (int j = 0; j < i; j++)
|
||||
{
|
||||
double aij = elmat(i,j), aji = elmat(j,i);
|
||||
real_t aij = elmat(i,j), aji = elmat(j,i);
|
||||
elmat(i,j) = sigma*aji - aij;
|
||||
elmat(j,i) = sigma*aij - aji;
|
||||
}
|
||||
@@ -3659,7 +3659,7 @@ void DGDiffusionIntegrator::AssembleFaceMatrix(
|
||||
void DGElasticityIntegrator::AssembleBlock(
|
||||
const int dim, const int row_ndofs, const int col_ndofs,
|
||||
const int row_offset, const int col_offset,
|
||||
const double jmatcoef, const Vector &col_nL, const Vector &col_nM,
|
||||
const real_t jmatcoef, const Vector &col_nL, const Vector &col_nM,
|
||||
const Vector &row_shape, const Vector &col_shape,
|
||||
const Vector &col_dshape_dnM, const DenseMatrix &col_dshape,
|
||||
DenseMatrix &elmat, DenseMatrix &jmat)
|
||||
@@ -3668,12 +3668,12 @@ void DGElasticityIntegrator::AssembleBlock(
|
||||
{
|
||||
for (int jdof = 0; jdof < col_ndofs; ++jdof, ++j)
|
||||
{
|
||||
const double t2 = col_dshape_dnM(jdof);
|
||||
const real_t t2 = col_dshape_dnM(jdof);
|
||||
for (int im = 0, i = row_offset; im < dim; ++im)
|
||||
{
|
||||
const double t1 = col_dshape(jdof, jm) * col_nL(im);
|
||||
const double t3 = col_dshape(jdof, im) * col_nM(jm);
|
||||
const double tt = t1 + ((im == jm) ? t2 : 0.0) + t3;
|
||||
const real_t t1 = col_dshape(jdof, jm) * col_nL(im);
|
||||
const real_t t3 = col_dshape(jdof, im) * col_nM(jm);
|
||||
const real_t tt = t1 + ((im == jm) ? t2 : 0.0) + t3;
|
||||
for (int idof = 0; idof < row_ndofs; ++idof, ++i)
|
||||
{
|
||||
elmat(i, j) += row_shape(idof) * tt;
|
||||
@@ -3690,7 +3690,7 @@ void DGElasticityIntegrator::AssembleBlock(
|
||||
const int io = row_offset + d*row_ndofs;
|
||||
for (int jdof = 0, j = jo; jdof < col_ndofs; ++jdof, ++j)
|
||||
{
|
||||
const double sj = jmatcoef * col_shape(jdof);
|
||||
const real_t sj = jmatcoef * col_shape(jdof);
|
||||
for (int i = max(io,j), idof = i - io; idof < row_ndofs; ++idof, ++i)
|
||||
{
|
||||
jmat(i, j) += row_shape(idof) * sj;
|
||||
@@ -3790,7 +3790,7 @@ void DGElasticityIntegrator::AssembleFaceMatrix(
|
||||
CalcOrtho(Trans.Jacobian(), nor);
|
||||
}
|
||||
|
||||
double w, wLM;
|
||||
real_t w, wLM;
|
||||
if (ndofs2)
|
||||
{
|
||||
el2.CalcShape(eip2, shape2);
|
||||
@@ -3799,9 +3799,9 @@ void DGElasticityIntegrator::AssembleFaceMatrix(
|
||||
Mult(dshape2, adjJ, dshape2_ps);
|
||||
|
||||
w = ip.weight/2;
|
||||
const double w2 = w / Trans.Elem2->Weight();
|
||||
const double wL2 = w2 * lambda->Eval(*Trans.Elem2, eip2);
|
||||
const double wM2 = w2 * mu->Eval(*Trans.Elem2, eip2);
|
||||
const real_t w2 = w / Trans.Elem2->Weight();
|
||||
const real_t wL2 = w2 * lambda->Eval(*Trans.Elem2, eip2);
|
||||
const real_t wM2 = w2 * mu->Eval(*Trans.Elem2, eip2);
|
||||
nL2.Set(wL2, nor);
|
||||
nM2.Set(wM2, nor);
|
||||
wLM = (wL2 + 2.0*wM2);
|
||||
@@ -3814,16 +3814,16 @@ void DGElasticityIntegrator::AssembleFaceMatrix(
|
||||
}
|
||||
|
||||
{
|
||||
const double w1 = w / Trans.Elem1->Weight();
|
||||
const double wL1 = w1 * lambda->Eval(*Trans.Elem1, eip1);
|
||||
const double wM1 = w1 * mu->Eval(*Trans.Elem1, eip1);
|
||||
const real_t w1 = w / Trans.Elem1->Weight();
|
||||
const real_t wL1 = w1 * lambda->Eval(*Trans.Elem1, eip1);
|
||||
const real_t wM1 = w1 * mu->Eval(*Trans.Elem1, eip1);
|
||||
nL1.Set(wL1, nor);
|
||||
nM1.Set(wM1, nor);
|
||||
wLM += (wL1 + 2.0*wM1);
|
||||
dshape1_ps.Mult(nM1, dshape1_dnM);
|
||||
}
|
||||
|
||||
const double jmatcoef = kappa * (nor*nor) * wLM;
|
||||
const real_t jmatcoef = kappa * (nor*nor) * wLM;
|
||||
|
||||
// (1,1) block
|
||||
AssembleBlock(
|
||||
@@ -3856,7 +3856,7 @@ void DGElasticityIntegrator::AssembleFaceMatrix(
|
||||
{
|
||||
for (int j = 0; j < i; ++j)
|
||||
{
|
||||
double aij = elmat(i,j), aji = elmat(j,i), mij = jmat(i,j);
|
||||
real_t aij = elmat(i,j), aji = elmat(j,i), mij = jmat(i,j);
|
||||
elmat(i,j) = alpha*aji - aij + mij;
|
||||
elmat(j,i) = alpha*aij - aji + mij;
|
||||
}
|
||||
@@ -3869,7 +3869,7 @@ void DGElasticityIntegrator::AssembleFaceMatrix(
|
||||
{
|
||||
for (int j = 0; j < i; ++j)
|
||||
{
|
||||
double aij = elmat(i,j), aji = elmat(j,i);
|
||||
real_t aij = elmat(i,j), aji = elmat(j,i);
|
||||
elmat(i,j) = alpha*aji - aij;
|
||||
elmat(j,i) = alpha*aij - aji;
|
||||
}
|
||||
@@ -3887,7 +3887,7 @@ void TraceJumpIntegrator::AssembleFaceMatrix(
|
||||
int i, j, face_ndof, ndof1, ndof2;
|
||||
int order;
|
||||
|
||||
double w;
|
||||
real_t w;
|
||||
|
||||
face_ndof = trial_face_fe.GetDof();
|
||||
ndof1 = test_fe1.GetDof();
|
||||
@@ -4095,7 +4095,7 @@ void TraceIntegrator::AssembleTraceFaceMatrix(int elem,
|
||||
MFEM_VERIFY(elem == Trans.Elem2->ElementNo, "Elem != Trans.Elem2->ElementNo");
|
||||
}
|
||||
|
||||
double scale = 1.0;
|
||||
real_t scale = 1.0;
|
||||
if (iel != elem) { scale = -1.; }
|
||||
for (int p = 0; p < ir->GetNPoints(); p++)
|
||||
{
|
||||
@@ -4161,7 +4161,7 @@ void NormalTraceIntegrator::AssembleTraceFaceMatrix(int elem,
|
||||
MFEM_VERIFY(elem == Trans.Elem2->ElementNo, "Elem != Trans.Elem2->ElementNo");
|
||||
}
|
||||
|
||||
double scale = 1.0;
|
||||
real_t scale = 1.0;
|
||||
if (iel != elem) { scale = -1.; }
|
||||
|
||||
for (int p = 0; p < ir->GetNPoints(); p++)
|
||||
@@ -4240,7 +4240,7 @@ void TangentTraceIntegrator::AssembleTraceFaceMatrix(int elem,
|
||||
MFEM_VERIFY(elem == Trans.Elem2->ElementNo, "Elem != Trans.Elem2->ElementNo");
|
||||
}
|
||||
|
||||
double scale = 1.0;
|
||||
real_t scale = 1.0;
|
||||
if (iel != elem) { scale = -1.; }
|
||||
for (int p = 0; p < ir->GetNPoints(); p++)
|
||||
{
|
||||
@@ -4264,7 +4264,7 @@ void TangentTraceIntegrator::AssembleTraceFaceMatrix(int elem,
|
||||
// rotate
|
||||
cross_product(normal, shape, shape_n);
|
||||
|
||||
const double w = scale*ip.weight;
|
||||
const real_t w = scale*ip.weight;
|
||||
AddMult_a_ABt(w,shape_n, face_shape, elmat);
|
||||
}
|
||||
}
|
||||
|
||||
+33
-33
@@ -263,7 +263,7 @@ public:
|
||||
for anisotropic error estimation.
|
||||
@returns The computed energy.
|
||||
*/
|
||||
virtual double ComputeFluxEnergy(const FiniteElement &fluxelem,
|
||||
virtual real_t ComputeFluxEnergy(const FiniteElement &fluxelem,
|
||||
ElementTransformation &Trans,
|
||||
Vector &flux, Vector *d_energy = NULL)
|
||||
{ return 0.0; }
|
||||
@@ -2151,7 +2151,7 @@ private:
|
||||
std::vector<std::vector<Vector>> reducedWeights;
|
||||
std::vector<IntArrayVar2D> reducedIDs;
|
||||
std::vector<Array<int>> pQ1D, pD1D;
|
||||
std::vector<std::vector<Array2D<double>>> pB, pG;
|
||||
std::vector<std::vector<Array2D<real_t>>> pB, pG;
|
||||
std::vector<IntArrayVar2D> pminD, pmaxD, pminQ, pmaxQ, pminDD, pmaxDD;
|
||||
|
||||
std::vector<Array<const IntegrationRule*>> pir1d;
|
||||
@@ -2226,7 +2226,7 @@ public:
|
||||
Vector &flux, bool with_coef = true,
|
||||
const IntegrationRule *ir = NULL);
|
||||
|
||||
virtual double ComputeFluxEnergy(const FiniteElement &fluxelem,
|
||||
virtual real_t ComputeFluxEnergy(const FiniteElement &fluxelem,
|
||||
ElementTransformation &Trans,
|
||||
Vector &flux, Vector *d_energy = NULL);
|
||||
|
||||
@@ -2345,7 +2345,7 @@ class ConvectionIntegrator : public BilinearFormIntegrator
|
||||
{
|
||||
protected:
|
||||
VectorCoefficient *Q;
|
||||
double alpha;
|
||||
real_t alpha;
|
||||
// PA extension
|
||||
Vector pa_data;
|
||||
const DofToQuad *maps; ///< Not owned
|
||||
@@ -2359,7 +2359,7 @@ private:
|
||||
#endif
|
||||
|
||||
public:
|
||||
ConvectionIntegrator(VectorCoefficient &q, double a = 1.0)
|
||||
ConvectionIntegrator(VectorCoefficient &q, real_t a = 1.0)
|
||||
: Q(&q) { alpha = a; }
|
||||
|
||||
virtual void AssembleElementMatrix(const FiniteElement &,
|
||||
@@ -2402,7 +2402,7 @@ using NonconservativeConvectionIntegrator = ConvectionIntegrator;
|
||||
class ConservativeConvectionIntegrator : public TransposeIntegrator
|
||||
{
|
||||
public:
|
||||
ConservativeConvectionIntegrator(VectorCoefficient &q, double a = 1.0)
|
||||
ConservativeConvectionIntegrator(VectorCoefficient &q, real_t a = 1.0)
|
||||
: TransposeIntegrator(new ConvectionIntegrator(q, -a)) { }
|
||||
};
|
||||
|
||||
@@ -2411,14 +2411,14 @@ class GroupConvectionIntegrator : public BilinearFormIntegrator
|
||||
{
|
||||
protected:
|
||||
VectorCoefficient *Q;
|
||||
double alpha;
|
||||
real_t alpha;
|
||||
|
||||
private:
|
||||
DenseMatrix dshape, adjJ, Q_nodal, grad;
|
||||
Vector shape;
|
||||
|
||||
public:
|
||||
GroupConvectionIntegrator(VectorCoefficient &q, double a = 1.0)
|
||||
GroupConvectionIntegrator(VectorCoefficient &q, real_t a = 1.0)
|
||||
: Q(&q) { alpha = a; }
|
||||
virtual void AssembleElementMatrix(const FiniteElement &,
|
||||
ElementTransformation &,
|
||||
@@ -2663,7 +2663,7 @@ public:
|
||||
Vector &flux, bool with_coef,
|
||||
const IntegrationRule *ir = NULL);
|
||||
|
||||
virtual double ComputeFluxEnergy(const FiniteElement &fluxelem,
|
||||
virtual real_t ComputeFluxEnergy(const FiniteElement &fluxelem,
|
||||
ElementTransformation &Trans,
|
||||
Vector &flux, Vector *d_energy = NULL);
|
||||
|
||||
@@ -2697,7 +2697,7 @@ public:
|
||||
ElementTransformation &Trans,
|
||||
DenseMatrix &elmat);
|
||||
/// Compute element energy: \f$ \frac{1}{2} (\mathrm{curl}(u), \mathrm{curl}(u))_E\f$
|
||||
virtual double GetElementEnergy(const FiniteElement &el,
|
||||
virtual real_t GetElementEnergy(const FiniteElement &el,
|
||||
ElementTransformation &Tr,
|
||||
const Vector &elfun);
|
||||
};
|
||||
@@ -2994,7 +2994,7 @@ class ElasticityIntegrator : public BilinearFormIntegrator
|
||||
friend class ElasticityComponentIntegrator;
|
||||
|
||||
protected:
|
||||
double q_lambda, q_mu;
|
||||
real_t q_lambda, q_mu;
|
||||
Coefficient *lambda, *mu;
|
||||
|
||||
private:
|
||||
@@ -3025,7 +3025,7 @@ public:
|
||||
{ lambda = &l; mu = &m; }
|
||||
/** With this constructor \f$\lambda = q_l * m\f$ and \f$\mu = q_m * m\f$
|
||||
if \f$dim * q_l + 2 * q_m = 0\f$ then \f$\tr(\sigma) = 0\f$. */
|
||||
ElasticityIntegrator(Coefficient &m, double q_l, double q_m)
|
||||
ElasticityIntegrator(Coefficient &m, real_t q_l, real_t q_m)
|
||||
{ lambda = NULL; mu = &m; q_lambda = q_l; q_mu = q_m; }
|
||||
|
||||
virtual void AssembleElementMatrix(const FiniteElement &el,
|
||||
@@ -3065,7 +3065,7 @@ public:
|
||||
symmetric part of the (symmetric) stress tensor. The order of the
|
||||
components is: \f$s_xx, s_yy, s_xy\f$ in 2D, and \f$s_xx, s_yy, s_zz, s_xy, s_xz,
|
||||
s_yz\f$ in 3D. */
|
||||
virtual double ComputeFluxEnergy(const FiniteElement &fluxelem,
|
||||
virtual real_t ComputeFluxEnergy(const FiniteElement &fluxelem,
|
||||
ElementTransformation &Trans,
|
||||
Vector &flux, Vector *d_energy = NULL);
|
||||
};
|
||||
@@ -3133,7 +3133,7 @@ class DGTraceIntegrator : public BilinearFormIntegrator
|
||||
protected:
|
||||
Coefficient *rho;
|
||||
VectorCoefficient *u;
|
||||
double alpha, beta;
|
||||
real_t alpha, beta;
|
||||
// PA extension
|
||||
Vector pa_data;
|
||||
const DofToQuad *maps; ///< Not owned
|
||||
@@ -3145,15 +3145,15 @@ private:
|
||||
|
||||
public:
|
||||
/// Construct integrator with \f$\rho = 1\f$, \f$\beta = \alpha/2\f$.
|
||||
DGTraceIntegrator(VectorCoefficient &u_, double a)
|
||||
DGTraceIntegrator(VectorCoefficient &u_, real_t a)
|
||||
{ rho = NULL; u = &u_; alpha = a; beta = 0.5*a; }
|
||||
|
||||
/// Construct integrator with \f$\rho = 1\f$.
|
||||
DGTraceIntegrator(VectorCoefficient &u_, double a, double b)
|
||||
DGTraceIntegrator(VectorCoefficient &u_, real_t a, real_t b)
|
||||
{ rho = NULL; u = &u_; alpha = a; beta = b; }
|
||||
|
||||
DGTraceIntegrator(Coefficient &rho_, VectorCoefficient &u_,
|
||||
double a, double b)
|
||||
real_t a, real_t b)
|
||||
{ rho = &rho_; u = &u_; alpha = a; beta = b; }
|
||||
|
||||
using BilinearFormIntegrator::AssembleFaceMatrix;
|
||||
@@ -3202,14 +3202,14 @@ using ConservativeDGTraceIntegrator = DGTraceIntegrator;
|
||||
class NonconservativeDGTraceIntegrator : public TransposeIntegrator
|
||||
{
|
||||
public:
|
||||
NonconservativeDGTraceIntegrator(VectorCoefficient &u, double a)
|
||||
NonconservativeDGTraceIntegrator(VectorCoefficient &u, real_t a)
|
||||
: TransposeIntegrator(new DGTraceIntegrator(u, -a, 0.5*a)) { }
|
||||
|
||||
NonconservativeDGTraceIntegrator(VectorCoefficient &u, double a, double b)
|
||||
NonconservativeDGTraceIntegrator(VectorCoefficient &u, real_t a, real_t b)
|
||||
: TransposeIntegrator(new DGTraceIntegrator(u, -a, b)) { }
|
||||
|
||||
NonconservativeDGTraceIntegrator(Coefficient &rho, VectorCoefficient &u,
|
||||
double a, double b)
|
||||
real_t a, real_t b)
|
||||
: TransposeIntegrator(new DGTraceIntegrator(rho, u, -a, b)) { }
|
||||
};
|
||||
|
||||
@@ -3232,18 +3232,18 @@ class DGDiffusionIntegrator : public BilinearFormIntegrator
|
||||
protected:
|
||||
Coefficient *Q;
|
||||
MatrixCoefficient *MQ;
|
||||
double sigma, kappa;
|
||||
real_t sigma, kappa;
|
||||
|
||||
// these are not thread-safe!
|
||||
Vector shape1, shape2, dshape1dn, dshape2dn, nor, nh, ni;
|
||||
DenseMatrix jmat, dshape1, dshape2, mq, adjJ;
|
||||
|
||||
public:
|
||||
DGDiffusionIntegrator(const double s, const double k)
|
||||
DGDiffusionIntegrator(const real_t s, const real_t k)
|
||||
: Q(NULL), MQ(NULL), sigma(s), kappa(k) { }
|
||||
DGDiffusionIntegrator(Coefficient &q, const double s, const double k)
|
||||
DGDiffusionIntegrator(Coefficient &q, const real_t s, const real_t k)
|
||||
: Q(&q), MQ(NULL), sigma(s), kappa(k) { }
|
||||
DGDiffusionIntegrator(MatrixCoefficient &q, const double s, const double k)
|
||||
DGDiffusionIntegrator(MatrixCoefficient &q, const real_t s, const real_t k)
|
||||
: Q(NULL), MQ(&q), sigma(s), kappa(k) { }
|
||||
using BilinearFormIntegrator::AssembleFaceMatrix;
|
||||
virtual void AssembleFaceMatrix(const FiniteElement &el1,
|
||||
@@ -3275,11 +3275,11 @@ public:
|
||||
class DGDiffusionBR2Integrator : public BilinearFormIntegrator
|
||||
{
|
||||
protected:
|
||||
double eta;
|
||||
real_t eta;
|
||||
|
||||
// Block factorizations of local mass matrices, with offsets for the case of
|
||||
// not equally sized blocks (mixed meshes, p-refinement)
|
||||
Array<double> Minv;
|
||||
Array<real_t> Minv;
|
||||
Array<int> ipiv;
|
||||
Array<int> ipiv_offsets, Minv_offsets;
|
||||
|
||||
@@ -3299,11 +3299,11 @@ protected:
|
||||
void PrecomputeMassInverse(class FiniteElementSpace &fes);
|
||||
|
||||
public:
|
||||
DGDiffusionBR2Integrator(class FiniteElementSpace &fes, double e = 1.0);
|
||||
DGDiffusionBR2Integrator(class FiniteElementSpace &fes, real_t e = 1.0);
|
||||
DGDiffusionBR2Integrator(class FiniteElementSpace &fes, Coefficient &Q_,
|
||||
double e = 1.0);
|
||||
real_t e = 1.0);
|
||||
MFEM_DEPRECATED DGDiffusionBR2Integrator(class FiniteElementSpace *fes,
|
||||
double e = 1.0);
|
||||
real_t e = 1.0);
|
||||
|
||||
using BilinearFormIntegrator::AssembleFaceMatrix;
|
||||
virtual void AssembleFaceMatrix(const FiniteElement &el1,
|
||||
@@ -3375,11 +3375,11 @@ public:
|
||||
class DGElasticityIntegrator : public BilinearFormIntegrator
|
||||
{
|
||||
public:
|
||||
DGElasticityIntegrator(double alpha_, double kappa_)
|
||||
DGElasticityIntegrator(real_t alpha_, real_t kappa_)
|
||||
: lambda(NULL), mu(NULL), alpha(alpha_), kappa(kappa_) { }
|
||||
|
||||
DGElasticityIntegrator(Coefficient &lambda_, Coefficient &mu_,
|
||||
double alpha_, double kappa_)
|
||||
real_t alpha_, real_t kappa_)
|
||||
: lambda(&lambda_), mu(&mu_), alpha(alpha_), kappa(kappa_) { }
|
||||
|
||||
using BilinearFormIntegrator::AssembleFaceMatrix;
|
||||
@@ -3390,7 +3390,7 @@ public:
|
||||
|
||||
protected:
|
||||
Coefficient *lambda, *mu;
|
||||
double alpha, kappa;
|
||||
real_t alpha, kappa;
|
||||
|
||||
#ifndef MFEM_THREAD_SAFE
|
||||
// values of all scalar basis functions for one component of u (which is a
|
||||
@@ -3416,7 +3416,7 @@ protected:
|
||||
static void AssembleBlock(
|
||||
const int dim, const int row_ndofs, const int col_ndofs,
|
||||
const int row_offset, const int col_offset,
|
||||
const double jmatcoef, const Vector &col_nL, const Vector &col_nM,
|
||||
const real_t jmatcoef, const Vector &col_nL, const Vector &col_nM,
|
||||
const Vector &row_shape, const Vector &col_shape,
|
||||
const Vector &col_dshape_dnM, const DenseMatrix &col_dshape,
|
||||
DenseMatrix &elmat, DenseMatrix &jmat);
|
||||
|
||||
@@ -70,7 +70,7 @@ void Operator::Mult(const mfem::Vector &x, mfem::Vector &y) const
|
||||
}
|
||||
|
||||
void Operator::AddMult(const mfem::Vector &x, mfem::Vector &y,
|
||||
const double a) const
|
||||
const real_t a) const
|
||||
{
|
||||
#ifdef MFEM_USE_CEED
|
||||
MFEM_VERIFY(a == 1.0, "General coefficient case is not yet supported!");
|
||||
|
||||
@@ -39,7 +39,7 @@ public:
|
||||
#endif
|
||||
void Mult(const mfem::Vector &x, mfem::Vector &y) const override;
|
||||
void AddMult(const mfem::Vector &x, mfem::Vector &y,
|
||||
const double a = 1.0) const override;
|
||||
const real_t a = 1.0) const override;
|
||||
void GetDiagonal(mfem::Vector &diag) const;
|
||||
using mfem::Operator::SetupRAP;
|
||||
virtual ~Operator()
|
||||
|
||||
+91
-87
@@ -73,7 +73,7 @@ void ConstantCoefficient::Project(QuadratureFunction &qf)
|
||||
qf = constant;
|
||||
}
|
||||
|
||||
double PWConstCoefficient::Eval(ElementTransformation & T,
|
||||
real_t PWConstCoefficient::Eval(ElementTransformation & T,
|
||||
const IntegrationPoint & ip)
|
||||
{
|
||||
int att = T.Attribute;
|
||||
@@ -97,7 +97,7 @@ void PWCoefficient::InitMap(const Array<int> & attr,
|
||||
}
|
||||
}
|
||||
|
||||
void PWCoefficient::SetTime(double t)
|
||||
void PWCoefficient::SetTime(real_t t)
|
||||
{
|
||||
Coefficient::SetTime(t);
|
||||
|
||||
@@ -111,7 +111,7 @@ void PWCoefficient::SetTime(double t)
|
||||
}
|
||||
}
|
||||
|
||||
double PWCoefficient::Eval(ElementTransformation &T,
|
||||
real_t PWCoefficient::Eval(ElementTransformation &T,
|
||||
const IntegrationPoint &ip)
|
||||
{
|
||||
const int att = T.Attribute;
|
||||
@@ -126,10 +126,10 @@ double PWCoefficient::Eval(ElementTransformation &T,
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
double FunctionCoefficient::Eval(ElementTransformation & T,
|
||||
real_t FunctionCoefficient::Eval(ElementTransformation & T,
|
||||
const IntegrationPoint & ip)
|
||||
{
|
||||
double x[3];
|
||||
real_t x[3];
|
||||
Vector transip(x, 3);
|
||||
|
||||
T.Transform(ip, transip);
|
||||
@@ -144,42 +144,42 @@ double FunctionCoefficient::Eval(ElementTransformation & T,
|
||||
}
|
||||
}
|
||||
|
||||
double CartesianCoefficient::Eval(ElementTransformation & T,
|
||||
real_t CartesianCoefficient::Eval(ElementTransformation & T,
|
||||
const IntegrationPoint & ip)
|
||||
{
|
||||
T.Transform(ip, transip);
|
||||
return transip[comp];
|
||||
}
|
||||
|
||||
double CylindricalRadialCoefficient::Eval(ElementTransformation & T,
|
||||
real_t CylindricalRadialCoefficient::Eval(ElementTransformation & T,
|
||||
const IntegrationPoint & ip)
|
||||
{
|
||||
T.Transform(ip, transip);
|
||||
return sqrt(transip[0] * transip[0] + transip[1] * transip[1]);
|
||||
}
|
||||
|
||||
double CylindricalAzimuthalCoefficient::Eval(ElementTransformation & T,
|
||||
real_t CylindricalAzimuthalCoefficient::Eval(ElementTransformation & T,
|
||||
const IntegrationPoint & ip)
|
||||
{
|
||||
T.Transform(ip, transip);
|
||||
return atan2(transip[1], transip[0]);
|
||||
}
|
||||
|
||||
double SphericalRadialCoefficient::Eval(ElementTransformation & T,
|
||||
real_t SphericalRadialCoefficient::Eval(ElementTransformation & T,
|
||||
const IntegrationPoint & ip)
|
||||
{
|
||||
T.Transform(ip, transip);
|
||||
return sqrt(transip * transip);
|
||||
}
|
||||
|
||||
double SphericalAzimuthalCoefficient::Eval(ElementTransformation & T,
|
||||
real_t SphericalAzimuthalCoefficient::Eval(ElementTransformation & T,
|
||||
const IntegrationPoint & ip)
|
||||
{
|
||||
T.Transform(ip, transip);
|
||||
return atan2(transip[1], transip[0]);
|
||||
}
|
||||
|
||||
double SphericalPolarCoefficient::Eval(ElementTransformation & T,
|
||||
real_t SphericalPolarCoefficient::Eval(ElementTransformation & T,
|
||||
const IntegrationPoint & ip)
|
||||
{
|
||||
T.Transform(ip, transip);
|
||||
@@ -187,7 +187,7 @@ double SphericalPolarCoefficient::Eval(ElementTransformation & T,
|
||||
transip[2]);
|
||||
}
|
||||
|
||||
double GridFunctionCoefficient::Eval (ElementTransformation &T,
|
||||
real_t GridFunctionCoefficient::Eval (ElementTransformation &T,
|
||||
const IntegrationPoint &ip)
|
||||
{
|
||||
Mesh *gf_mesh = GridF->FESpace()->GetMesh();
|
||||
@@ -208,14 +208,14 @@ void GridFunctionCoefficient::Project(QuadratureFunction &qf)
|
||||
qf.ProjectGridFunction(*GridF);
|
||||
}
|
||||
|
||||
void TransformedCoefficient::SetTime(double t)
|
||||
void TransformedCoefficient::SetTime(real_t t)
|
||||
{
|
||||
if (Q1) { Q1->SetTime(t); }
|
||||
if (Q2) { Q2->SetTime(t); }
|
||||
this->Coefficient::SetTime(t);
|
||||
}
|
||||
|
||||
double TransformedCoefficient::Eval(ElementTransformation &T,
|
||||
real_t TransformedCoefficient::Eval(ElementTransformation &T,
|
||||
const IntegrationPoint &ip)
|
||||
{
|
||||
if (Q2)
|
||||
@@ -229,7 +229,7 @@ double TransformedCoefficient::Eval(ElementTransformation &T,
|
||||
}
|
||||
}
|
||||
|
||||
void DeltaCoefficient::SetTime(double t)
|
||||
void DeltaCoefficient::SetTime(real_t t)
|
||||
{
|
||||
if (weight) { weight->SetTime(t); }
|
||||
this->Coefficient::SetTime(t);
|
||||
@@ -249,14 +249,14 @@ void DeltaCoefficient::GetDeltaCenter(Vector& vcenter)
|
||||
vcenter = center;
|
||||
}
|
||||
|
||||
double DeltaCoefficient::EvalDelta(ElementTransformation &T,
|
||||
real_t DeltaCoefficient::EvalDelta(ElementTransformation &T,
|
||||
const IntegrationPoint &ip)
|
||||
{
|
||||
double w = Scale();
|
||||
real_t w = Scale();
|
||||
return weight ? weight->Eval(T, ip, GetTime())*w : w;
|
||||
}
|
||||
|
||||
void RestrictedCoefficient::SetTime(double t)
|
||||
void RestrictedCoefficient::SetTime(real_t t)
|
||||
{
|
||||
if (c) { c->SetTime(t); }
|
||||
this->Coefficient::SetTime(t);
|
||||
@@ -324,7 +324,7 @@ void PWVectorCoefficient::UpdateCoefficient(int attr, VectorCoefficient & coef)
|
||||
pieces[attr] = &coef;
|
||||
}
|
||||
|
||||
void PWVectorCoefficient::SetTime(double t)
|
||||
void PWVectorCoefficient::SetTime(real_t t)
|
||||
{
|
||||
VectorCoefficient::SetTime(t);
|
||||
|
||||
@@ -366,7 +366,7 @@ void PositionVectorCoefficient::Eval(Vector &V, ElementTransformation &T,
|
||||
void VectorFunctionCoefficient::Eval(Vector &V, ElementTransformation &T,
|
||||
const IntegrationPoint &ip)
|
||||
{
|
||||
double x[3];
|
||||
real_t x[3];
|
||||
Vector transip(x, 3);
|
||||
|
||||
T.Transform(ip, transip);
|
||||
@@ -396,7 +396,7 @@ VectorArrayCoefficient::VectorArrayCoefficient (int dim)
|
||||
}
|
||||
}
|
||||
|
||||
void VectorArrayCoefficient::SetTime(double t)
|
||||
void VectorArrayCoefficient::SetTime(real_t t)
|
||||
{
|
||||
for (int i = 0; i < vdim; i++)
|
||||
{
|
||||
@@ -553,7 +553,7 @@ DivergenceGridFunctionCoefficient::DivergenceGridFunctionCoefficient (
|
||||
GridFunc = gf;
|
||||
}
|
||||
|
||||
double DivergenceGridFunctionCoefficient::Eval(ElementTransformation &T,
|
||||
real_t DivergenceGridFunctionCoefficient::Eval(ElementTransformation &T,
|
||||
const IntegrationPoint &ip)
|
||||
{
|
||||
Mesh *gf_mesh = GridFunc->FESpace()->GetMesh();
|
||||
@@ -569,7 +569,7 @@ double DivergenceGridFunctionCoefficient::Eval(ElementTransformation &T,
|
||||
}
|
||||
}
|
||||
|
||||
void VectorDeltaCoefficient::SetTime(double t)
|
||||
void VectorDeltaCoefficient::SetTime(real_t t)
|
||||
{
|
||||
d.SetTime(t);
|
||||
this->VectorCoefficient::SetTime(t);
|
||||
@@ -589,7 +589,7 @@ void VectorDeltaCoefficient::EvalDelta(
|
||||
V *= d.EvalDelta(T, ip);
|
||||
}
|
||||
|
||||
void VectorRestrictedCoefficient::SetTime(double t)
|
||||
void VectorRestrictedCoefficient::SetTime(real_t t)
|
||||
{
|
||||
if (c) { c->SetTime(t); }
|
||||
this->VectorCoefficient::SetTime(t);
|
||||
@@ -682,7 +682,7 @@ void PWMatrixCoefficient::UpdateCoefficient(int attr, MatrixCoefficient & coef)
|
||||
pieces[attr] = &coef;
|
||||
}
|
||||
|
||||
void PWMatrixCoefficient::SetTime(double t)
|
||||
void PWMatrixCoefficient::SetTime(real_t t)
|
||||
{
|
||||
MatrixCoefficient::SetTime(t);
|
||||
|
||||
@@ -714,7 +714,7 @@ void PWMatrixCoefficient::Eval(DenseMatrix &K, ElementTransformation &T,
|
||||
K = 0.0;
|
||||
}
|
||||
|
||||
void MatrixFunctionCoefficient::SetTime(double t)
|
||||
void MatrixFunctionCoefficient::SetTime(real_t t)
|
||||
{
|
||||
if (Q) { Q->SetTime(t); }
|
||||
this->MatrixCoefficient::SetTime(t);
|
||||
@@ -723,7 +723,7 @@ void MatrixFunctionCoefficient::SetTime(double t)
|
||||
void MatrixFunctionCoefficient::Eval(DenseMatrix &K, ElementTransformation &T,
|
||||
const IntegrationPoint &ip)
|
||||
{
|
||||
double x[3];
|
||||
real_t x[3];
|
||||
Vector transip(x, 3);
|
||||
|
||||
T.Transform(ip, transip);
|
||||
@@ -745,7 +745,7 @@ void MatrixFunctionCoefficient::Eval(DenseMatrix &K, ElementTransformation &T,
|
||||
{
|
||||
for (int j=i; j<width; ++j)
|
||||
{
|
||||
const double Kij = Ksym[j - i + os];
|
||||
const real_t Kij = Ksym[j - i + os];
|
||||
K(i,j) = Kij;
|
||||
if (j != i) { K(j,i) = Kij; }
|
||||
}
|
||||
@@ -782,7 +782,7 @@ void MatrixFunctionCoefficient::EvalSymmetric(Vector &K,
|
||||
MFEM_VERIFY(symmetric && height == width && SymmFunction,
|
||||
"MatrixFunctionCoefficient is not symmetric");
|
||||
|
||||
double x[3];
|
||||
real_t x[3];
|
||||
Vector transip(x, 3);
|
||||
|
||||
T.Transform(ip, transip);
|
||||
@@ -839,7 +839,7 @@ void SymmetricMatrixCoefficient::Eval(DenseMatrix &K, ElementTransformation &T,
|
||||
}
|
||||
}
|
||||
|
||||
void SymmetricMatrixFunctionCoefficient::SetTime(double t)
|
||||
void SymmetricMatrixFunctionCoefficient::SetTime(real_t t)
|
||||
{
|
||||
if (Q) { Q->SetTime(t); }
|
||||
MatrixCoefficient::SetTime(t);
|
||||
@@ -849,7 +849,7 @@ void SymmetricMatrixFunctionCoefficient::Eval(DenseSymmetricMatrix &K,
|
||||
ElementTransformation &T,
|
||||
const IntegrationPoint &ip)
|
||||
{
|
||||
double x[3];
|
||||
real_t x[3];
|
||||
Vector transip(x, 3);
|
||||
|
||||
T.Transform(ip, transip);
|
||||
@@ -887,7 +887,7 @@ MatrixArrayCoefficient::MatrixArrayCoefficient (int dim)
|
||||
}
|
||||
}
|
||||
|
||||
void MatrixArrayCoefficient::SetTime(double t)
|
||||
void MatrixArrayCoefficient::SetTime(real_t t)
|
||||
{
|
||||
for (int i=0; i < height*width; i++)
|
||||
{
|
||||
@@ -924,7 +924,7 @@ void MatrixArrayCoefficient::Eval(DenseMatrix &K, ElementTransformation &T,
|
||||
}
|
||||
}
|
||||
|
||||
void MatrixRestrictedCoefficient::SetTime(double t)
|
||||
void MatrixRestrictedCoefficient::SetTime(real_t t)
|
||||
{
|
||||
if (c) { c->SetTime(t); }
|
||||
this->MatrixCoefficient::SetTime(t);
|
||||
@@ -945,28 +945,28 @@ void MatrixRestrictedCoefficient::Eval(DenseMatrix &K, ElementTransformation &T,
|
||||
}
|
||||
}
|
||||
|
||||
void SumCoefficient::SetTime(double t)
|
||||
void SumCoefficient::SetTime(real_t t)
|
||||
{
|
||||
if (a) { a->SetTime(t); }
|
||||
if (b) { b->SetTime(t); }
|
||||
this->Coefficient::SetTime(t);
|
||||
}
|
||||
|
||||
void ProductCoefficient::SetTime(double t)
|
||||
void ProductCoefficient::SetTime(real_t t)
|
||||
{
|
||||
if (a) { a->SetTime(t); }
|
||||
if (b) { b->SetTime(t); }
|
||||
this->Coefficient::SetTime(t);
|
||||
}
|
||||
|
||||
void RatioCoefficient::SetTime(double t)
|
||||
void RatioCoefficient::SetTime(real_t t)
|
||||
{
|
||||
if (a) { a->SetTime(t); }
|
||||
if (b) { b->SetTime(t); }
|
||||
this->Coefficient::SetTime(t);
|
||||
}
|
||||
|
||||
void PowerCoefficient::SetTime(double t)
|
||||
void PowerCoefficient::SetTime(real_t t)
|
||||
{
|
||||
if (a) { a->SetTime(t); }
|
||||
this->Coefficient::SetTime(t);
|
||||
@@ -981,14 +981,14 @@ InnerProductCoefficient::InnerProductCoefficient(VectorCoefficient &A,
|
||||
"Arguments have incompatible dimensions.");
|
||||
}
|
||||
|
||||
void InnerProductCoefficient::SetTime(double t)
|
||||
void InnerProductCoefficient::SetTime(real_t t)
|
||||
{
|
||||
if (a) { a->SetTime(t); }
|
||||
if (b) { b->SetTime(t); }
|
||||
this->Coefficient::SetTime(t);
|
||||
}
|
||||
|
||||
double InnerProductCoefficient::Eval(ElementTransformation &T,
|
||||
real_t InnerProductCoefficient::Eval(ElementTransformation &T,
|
||||
const IntegrationPoint &ip)
|
||||
{
|
||||
a->Eval(va, T, ip);
|
||||
@@ -1005,14 +1005,14 @@ VectorRotProductCoefficient::VectorRotProductCoefficient(VectorCoefficient &A,
|
||||
"Arguments must have dimension equal to two.");
|
||||
}
|
||||
|
||||
void VectorRotProductCoefficient::SetTime(double t)
|
||||
void VectorRotProductCoefficient::SetTime(real_t t)
|
||||
{
|
||||
if (a) { a->SetTime(t); }
|
||||
if (b) { b->SetTime(t); }
|
||||
this->Coefficient::SetTime(t);
|
||||
}
|
||||
|
||||
double VectorRotProductCoefficient::Eval(ElementTransformation &T,
|
||||
real_t VectorRotProductCoefficient::Eval(ElementTransformation &T,
|
||||
const IntegrationPoint &ip)
|
||||
{
|
||||
a->Eval(va, T, ip);
|
||||
@@ -1028,13 +1028,13 @@ DeterminantCoefficient::DeterminantCoefficient(MatrixCoefficient &A)
|
||||
"Argument must be a square matrix.");
|
||||
}
|
||||
|
||||
void DeterminantCoefficient::SetTime(double t)
|
||||
void DeterminantCoefficient::SetTime(real_t t)
|
||||
{
|
||||
if (a) { a->SetTime(t); }
|
||||
this->Coefficient::SetTime(t);
|
||||
}
|
||||
|
||||
double DeterminantCoefficient::Eval(ElementTransformation &T,
|
||||
real_t DeterminantCoefficient::Eval(ElementTransformation &T,
|
||||
const IntegrationPoint &ip)
|
||||
{
|
||||
a->Eval(ma, T, ip);
|
||||
@@ -1053,7 +1053,7 @@ VectorSumCoefficient::VectorSumCoefficient(int dim)
|
||||
|
||||
VectorSumCoefficient::VectorSumCoefficient(VectorCoefficient &A_,
|
||||
VectorCoefficient &B_,
|
||||
double alpha_, double beta_)
|
||||
real_t alpha_, real_t beta_)
|
||||
: VectorCoefficient(A_.GetVDim()),
|
||||
ACoef(&A_), BCoef(&B_),
|
||||
A(A_.GetVDim()), B(A_.GetVDim()),
|
||||
@@ -1082,7 +1082,7 @@ VectorSumCoefficient::VectorSumCoefficient(VectorCoefficient &A_,
|
||||
"Arguments must have the same dimension.");
|
||||
}
|
||||
|
||||
void VectorSumCoefficient::SetTime(double t)
|
||||
void VectorSumCoefficient::SetTime(real_t t)
|
||||
{
|
||||
if (ACoef) { ACoef->SetTime(t); }
|
||||
if (BCoef) { BCoef->SetTime(t); }
|
||||
@@ -1103,7 +1103,7 @@ void VectorSumCoefficient::Eval(Vector &V, ElementTransformation &T,
|
||||
}
|
||||
|
||||
ScalarVectorProductCoefficient::ScalarVectorProductCoefficient(
|
||||
double A,
|
||||
real_t A,
|
||||
VectorCoefficient &B)
|
||||
: VectorCoefficient(B.GetVDim()), aConst(A), a(NULL), b(&B)
|
||||
{}
|
||||
@@ -1114,7 +1114,7 @@ ScalarVectorProductCoefficient::ScalarVectorProductCoefficient(
|
||||
: VectorCoefficient(B.GetVDim()), aConst(0.0), a(&A), b(&B)
|
||||
{}
|
||||
|
||||
void ScalarVectorProductCoefficient::SetTime(double t)
|
||||
void ScalarVectorProductCoefficient::SetTime(real_t t)
|
||||
{
|
||||
if (a) { a->SetTime(t); }
|
||||
if (b) { b->SetTime(t); }
|
||||
@@ -1124,17 +1124,17 @@ void ScalarVectorProductCoefficient::SetTime(double t)
|
||||
void ScalarVectorProductCoefficient::Eval(Vector &V, ElementTransformation &T,
|
||||
const IntegrationPoint &ip)
|
||||
{
|
||||
double sa = (a == NULL) ? aConst : a->Eval(T, ip);
|
||||
real_t sa = (a == NULL) ? aConst : a->Eval(T, ip);
|
||||
b->Eval(V, T, ip);
|
||||
V *= sa;
|
||||
}
|
||||
|
||||
NormalizedVectorCoefficient::NormalizedVectorCoefficient(VectorCoefficient &A,
|
||||
double tol_)
|
||||
real_t tol_)
|
||||
: VectorCoefficient(A.GetVDim()), a(&A), tol(tol_)
|
||||
{}
|
||||
|
||||
void NormalizedVectorCoefficient::SetTime(double t)
|
||||
void NormalizedVectorCoefficient::SetTime(real_t t)
|
||||
{
|
||||
if (a) { a->SetTime(t); }
|
||||
this->VectorCoefficient::SetTime(t);
|
||||
@@ -1144,7 +1144,7 @@ void NormalizedVectorCoefficient::Eval(Vector &V, ElementTransformation &T,
|
||||
const IntegrationPoint &ip)
|
||||
{
|
||||
a->Eval(V, T, ip);
|
||||
double nv = V.Norml2();
|
||||
real_t nv = V.Norml2();
|
||||
V *= (nv > tol) ? (1.0/nv) : 0.0;
|
||||
}
|
||||
|
||||
@@ -1158,7 +1158,7 @@ VectorCrossProductCoefficient::VectorCrossProductCoefficient(
|
||||
"Arguments must have dimension equal to three.");
|
||||
}
|
||||
|
||||
void VectorCrossProductCoefficient::SetTime(double t)
|
||||
void VectorCrossProductCoefficient::SetTime(real_t t)
|
||||
{
|
||||
if (a) { a->SetTime(t); }
|
||||
if (b) { b->SetTime(t); }
|
||||
@@ -1186,7 +1186,7 @@ MatrixVectorProductCoefficient::MatrixVectorProductCoefficient(
|
||||
"Arguments have incompatible dimensions.");
|
||||
}
|
||||
|
||||
void MatrixVectorProductCoefficient::SetTime(double t)
|
||||
void MatrixVectorProductCoefficient::SetTime(real_t t)
|
||||
{
|
||||
if (a) { a->SetTime(t); }
|
||||
if (b) { b->SetTime(t); }
|
||||
@@ -1212,7 +1212,7 @@ void IdentityMatrixCoefficient::Eval(DenseMatrix &M, ElementTransformation &T,
|
||||
|
||||
MatrixSumCoefficient::MatrixSumCoefficient(MatrixCoefficient &A,
|
||||
MatrixCoefficient &B,
|
||||
double alpha_, double beta_)
|
||||
real_t alpha_, real_t beta_)
|
||||
: MatrixCoefficient(A.GetHeight(), A.GetWidth()),
|
||||
a(&A), b(&B), alpha(alpha_), beta(beta_),
|
||||
ma(A.GetHeight(), A.GetWidth())
|
||||
@@ -1222,7 +1222,7 @@ MatrixSumCoefficient::MatrixSumCoefficient(MatrixCoefficient &A,
|
||||
"Arguments must have the same dimensions.");
|
||||
}
|
||||
|
||||
void MatrixSumCoefficient::SetTime(double t)
|
||||
void MatrixSumCoefficient::SetTime(real_t t)
|
||||
{
|
||||
if (a) { a->SetTime(t); }
|
||||
if (b) { b->SetTime(t); }
|
||||
@@ -1259,7 +1259,7 @@ void MatrixProductCoefficient::Eval(DenseMatrix &M, ElementTransformation &T,
|
||||
}
|
||||
|
||||
ScalarMatrixProductCoefficient::ScalarMatrixProductCoefficient(
|
||||
double A,
|
||||
real_t A,
|
||||
MatrixCoefficient &B)
|
||||
: MatrixCoefficient(B.GetHeight(), B.GetWidth()), aConst(A), a(NULL), b(&B)
|
||||
{}
|
||||
@@ -1270,7 +1270,7 @@ ScalarMatrixProductCoefficient::ScalarMatrixProductCoefficient(
|
||||
: MatrixCoefficient(B.GetHeight(), B.GetWidth()), aConst(0.0), a(&A), b(&B)
|
||||
{}
|
||||
|
||||
void ScalarMatrixProductCoefficient::SetTime(double t)
|
||||
void ScalarMatrixProductCoefficient::SetTime(real_t t)
|
||||
{
|
||||
if (a) { a->SetTime(t); }
|
||||
if (b) { b->SetTime(t); }
|
||||
@@ -1281,7 +1281,7 @@ void ScalarMatrixProductCoefficient::Eval(DenseMatrix &M,
|
||||
ElementTransformation &T,
|
||||
const IntegrationPoint &ip)
|
||||
{
|
||||
double sa = (a == NULL) ? aConst : a->Eval(T, ip);
|
||||
real_t sa = (a == NULL) ? aConst : a->Eval(T, ip);
|
||||
b->Eval(M, T, ip);
|
||||
M *= sa;
|
||||
}
|
||||
@@ -1290,7 +1290,7 @@ TransposeMatrixCoefficient::TransposeMatrixCoefficient(MatrixCoefficient &A)
|
||||
: MatrixCoefficient(A.GetWidth(), A.GetHeight()), a(&A)
|
||||
{}
|
||||
|
||||
void TransposeMatrixCoefficient::SetTime(double t)
|
||||
void TransposeMatrixCoefficient::SetTime(real_t t)
|
||||
{
|
||||
if (a) { a->SetTime(t); }
|
||||
this->MatrixCoefficient::SetTime(t);
|
||||
@@ -1312,7 +1312,7 @@ InverseMatrixCoefficient::InverseMatrixCoefficient(MatrixCoefficient &A)
|
||||
"Argument must be a square matrix.");
|
||||
}
|
||||
|
||||
void InverseMatrixCoefficient::SetTime(double t)
|
||||
void InverseMatrixCoefficient::SetTime(real_t t)
|
||||
{
|
||||
if (a) { a->SetTime(t); }
|
||||
this->MatrixCoefficient::SetTime(t);
|
||||
@@ -1332,7 +1332,7 @@ OuterProductCoefficient::OuterProductCoefficient(VectorCoefficient &A,
|
||||
va(A.GetVDim()), vb(B.GetVDim())
|
||||
{}
|
||||
|
||||
void OuterProductCoefficient::SetTime(double t)
|
||||
void OuterProductCoefficient::SetTime(real_t t)
|
||||
{
|
||||
if (a) { a->SetTime(t); }
|
||||
if (b) { b->SetTime(t); }
|
||||
@@ -1354,7 +1354,7 @@ void OuterProductCoefficient::Eval(DenseMatrix &M, ElementTransformation &T,
|
||||
}
|
||||
}
|
||||
|
||||
CrossCrossCoefficient::CrossCrossCoefficient(double A, VectorCoefficient &K)
|
||||
CrossCrossCoefficient::CrossCrossCoefficient(real_t A, VectorCoefficient &K)
|
||||
: MatrixCoefficient(K.GetVDim(), K.GetVDim()), aConst(A), a(NULL), k(&K),
|
||||
vk(K.GetVDim())
|
||||
{}
|
||||
@@ -1365,7 +1365,7 @@ CrossCrossCoefficient::CrossCrossCoefficient(Coefficient &A,
|
||||
vk(K.GetVDim())
|
||||
{}
|
||||
|
||||
void CrossCrossCoefficient::SetTime(double t)
|
||||
void CrossCrossCoefficient::SetTime(real_t t)
|
||||
{
|
||||
if (a) { a->SetTime(t); }
|
||||
if (k) { k->SetTime(t); }
|
||||
@@ -1378,7 +1378,7 @@ void CrossCrossCoefficient::Eval(DenseMatrix &M, ElementTransformation &T,
|
||||
k->Eval(vk, T, ip);
|
||||
M.SetSize(vk.Size(), vk.Size());
|
||||
M = 0.0;
|
||||
double k2 = vk*vk;
|
||||
real_t k2 = vk*vk;
|
||||
for (int i=0; i<vk.Size(); i++)
|
||||
{
|
||||
M(i, i) = k2;
|
||||
@@ -1390,10 +1390,10 @@ void CrossCrossCoefficient::Eval(DenseMatrix &M, ElementTransformation &T,
|
||||
M *= ((a == NULL ) ? aConst : a->Eval(T, ip) );
|
||||
}
|
||||
|
||||
double LpNormLoop(double p, Coefficient &coeff, Mesh &mesh,
|
||||
real_t LpNormLoop(real_t p, Coefficient &coeff, Mesh &mesh,
|
||||
const IntegrationRule *irs[])
|
||||
{
|
||||
double norm = 0.0;
|
||||
real_t norm = 0.0;
|
||||
ElementTransformation *tr;
|
||||
|
||||
for (int i = 0; i < mesh.GetNE(); i++)
|
||||
@@ -1404,7 +1404,7 @@ double LpNormLoop(double p, Coefficient &coeff, Mesh &mesh,
|
||||
{
|
||||
const IntegrationPoint &ip = ir.IntPoint(j);
|
||||
tr->SetIntPoint(&ip);
|
||||
double val = fabs(coeff.Eval(*tr, ip));
|
||||
real_t val = fabs(coeff.Eval(*tr, ip));
|
||||
if (p < infinity())
|
||||
{
|
||||
norm += ip.weight * tr->Weight() * pow(val, p);
|
||||
@@ -1421,14 +1421,14 @@ double LpNormLoop(double p, Coefficient &coeff, Mesh &mesh,
|
||||
return norm;
|
||||
}
|
||||
|
||||
double LpNormLoop(double p, VectorCoefficient &coeff, Mesh &mesh,
|
||||
real_t LpNormLoop(real_t p, VectorCoefficient &coeff, Mesh &mesh,
|
||||
const IntegrationRule *irs[])
|
||||
{
|
||||
double norm = 0.0;
|
||||
real_t norm = 0.0;
|
||||
ElementTransformation *tr;
|
||||
int vdim = coeff.GetVDim();
|
||||
Vector vval(vdim);
|
||||
double val;
|
||||
real_t val;
|
||||
|
||||
for (int i = 0; i < mesh.GetNE(); i++)
|
||||
{
|
||||
@@ -1463,10 +1463,10 @@ double LpNormLoop(double p, VectorCoefficient &coeff, Mesh &mesh,
|
||||
return norm;
|
||||
}
|
||||
|
||||
double ComputeLpNorm(double p, Coefficient &coeff, Mesh &mesh,
|
||||
real_t ComputeLpNorm(real_t p, Coefficient &coeff, Mesh &mesh,
|
||||
const IntegrationRule *irs[])
|
||||
{
|
||||
double norm = LpNormLoop(p, coeff, mesh, irs);
|
||||
real_t norm = LpNormLoop(p, coeff, mesh, irs);
|
||||
|
||||
if (p < infinity())
|
||||
{
|
||||
@@ -1484,10 +1484,10 @@ double ComputeLpNorm(double p, Coefficient &coeff, Mesh &mesh,
|
||||
return norm;
|
||||
}
|
||||
|
||||
double ComputeLpNorm(double p, VectorCoefficient &coeff, Mesh &mesh,
|
||||
real_t ComputeLpNorm(real_t p, VectorCoefficient &coeff, Mesh &mesh,
|
||||
const IntegrationRule *irs[])
|
||||
{
|
||||
double norm = LpNormLoop(p, coeff, mesh, irs);
|
||||
real_t norm = LpNormLoop(p, coeff, mesh, irs);
|
||||
|
||||
if (p < infinity())
|
||||
{
|
||||
@@ -1506,17 +1506,18 @@ double ComputeLpNorm(double p, VectorCoefficient &coeff, Mesh &mesh,
|
||||
}
|
||||
|
||||
#ifdef MFEM_USE_MPI
|
||||
double ComputeGlobalLpNorm(double p, Coefficient &coeff, ParMesh &pmesh,
|
||||
real_t ComputeGlobalLpNorm(real_t p, Coefficient &coeff, ParMesh &pmesh,
|
||||
const IntegrationRule *irs[])
|
||||
{
|
||||
double loc_norm = LpNormLoop(p, coeff, pmesh, irs);
|
||||
double glob_norm = 0;
|
||||
real_t loc_norm = LpNormLoop(p, coeff, pmesh, irs);
|
||||
real_t glob_norm = 0;
|
||||
|
||||
MPI_Comm comm = pmesh.GetComm();
|
||||
|
||||
if (p < infinity())
|
||||
{
|
||||
MPI_Allreduce(&loc_norm, &glob_norm, 1, MPI_DOUBLE, MPI_SUM, comm);
|
||||
MPI_Allreduce(&loc_norm, &glob_norm, 1, MPITypeMap<real_t>::mpi_type, MPI_SUM,
|
||||
comm);
|
||||
|
||||
// negative quadrature weights may cause norm to be negative
|
||||
if (glob_norm < 0.0)
|
||||
@@ -1530,23 +1531,25 @@ double ComputeGlobalLpNorm(double p, Coefficient &coeff, ParMesh &pmesh,
|
||||
}
|
||||
else
|
||||
{
|
||||
MPI_Allreduce(&loc_norm, &glob_norm, 1, MPI_DOUBLE, MPI_MAX, comm);
|
||||
MPI_Allreduce(&loc_norm, &glob_norm, 1, MPITypeMap<real_t>::mpi_type, MPI_MAX,
|
||||
comm);
|
||||
}
|
||||
|
||||
return glob_norm;
|
||||
}
|
||||
|
||||
double ComputeGlobalLpNorm(double p, VectorCoefficient &coeff, ParMesh &pmesh,
|
||||
real_t ComputeGlobalLpNorm(real_t p, VectorCoefficient &coeff, ParMesh &pmesh,
|
||||
const IntegrationRule *irs[])
|
||||
{
|
||||
double loc_norm = LpNormLoop(p, coeff, pmesh, irs);
|
||||
double glob_norm = 0;
|
||||
real_t loc_norm = LpNormLoop(p, coeff, pmesh, irs);
|
||||
real_t glob_norm = 0;
|
||||
|
||||
MPI_Comm comm = pmesh.GetComm();
|
||||
|
||||
if (p < infinity())
|
||||
{
|
||||
MPI_Allreduce(&loc_norm, &glob_norm, 1, MPI_DOUBLE, MPI_SUM, comm);
|
||||
MPI_Allreduce(&loc_norm, &glob_norm, 1, MPITypeMap<real_t>::mpi_type, MPI_SUM,
|
||||
comm);
|
||||
|
||||
// negative quadrature weights may cause norm to be negative
|
||||
if (glob_norm < 0.0)
|
||||
@@ -1560,7 +1563,8 @@ double ComputeGlobalLpNorm(double p, VectorCoefficient &coeff, ParMesh &pmesh,
|
||||
}
|
||||
else
|
||||
{
|
||||
MPI_Allreduce(&loc_norm, &glob_norm, 1, MPI_DOUBLE, MPI_MAX, comm);
|
||||
MPI_Allreduce(&loc_norm, &glob_norm, 1, MPITypeMap<real_t>::mpi_type, MPI_MAX,
|
||||
comm);
|
||||
}
|
||||
|
||||
return glob_norm;
|
||||
@@ -1627,7 +1631,7 @@ QuadratureFunctionCoefficient::QuadratureFunctionCoefficient(
|
||||
MFEM_VERIFY(qf.GetVDim() == 1, "QuadratureFunction's vdim must be 1");
|
||||
}
|
||||
|
||||
double QuadratureFunctionCoefficient::Eval(ElementTransformation &T,
|
||||
real_t QuadratureFunctionCoefficient::Eval(ElementTransformation &T,
|
||||
const IntegrationPoint &ip)
|
||||
{
|
||||
QuadF.HostRead();
|
||||
@@ -1777,7 +1781,7 @@ void CoefficientVector::MakeRef(const QuadratureFunction &qf_)
|
||||
Vector::MakeRef(const_cast<QuadratureFunction&>(qf_), 0, qf_.Size());
|
||||
}
|
||||
|
||||
void CoefficientVector::SetConstant(double constant)
|
||||
void CoefficientVector::SetConstant(real_t constant)
|
||||
{
|
||||
const int nq = (storage & CoefficientStorage::CONSTANTS) ? 1 : qs.GetSize();
|
||||
vdim = 1;
|
||||
@@ -1829,7 +1833,7 @@ void CoefficientVector::SetConstant(const DenseSymmetricMatrix &constant)
|
||||
{
|
||||
for (int vd = 0; vd < vdim; ++vd)
|
||||
{
|
||||
const double value = sym ? constant.GetData()[vd] : constant(vd % height,
|
||||
const real_t value = sym ? constant.GetData()[vd] : constant(vd % height,
|
||||
vd / height);
|
||||
(*this)[vd + iq*vdim] = value;
|
||||
}
|
||||
|
||||
+169
-169
File diff suppressed because it is too large
Load Diff
+7
-7
@@ -268,13 +268,13 @@ ComplexLinearForm::Assemble()
|
||||
lfi->SyncAliasMemory(*this);
|
||||
}
|
||||
|
||||
complex<double>
|
||||
complex<real_t>
|
||||
ComplexLinearForm::operator()(const ComplexGridFunction &gf) const
|
||||
{
|
||||
double s = (conv == ComplexOperator::HERMITIAN) ? 1.0 : -1.0;
|
||||
real_t s = (conv == ComplexOperator::HERMITIAN) ? 1.0 : -1.0;
|
||||
lfr->SyncMemory(*this);
|
||||
lfi->SyncMemory(*this);
|
||||
return complex<double>((*lfr)(gf.real()) - s * (*lfi)(gf.imag()),
|
||||
return complex<real_t>((*lfr)(gf.real()) - s * (*lfi)(gf.imag()),
|
||||
(*lfr)(gf.imag()) + s * (*lfi)(gf.real()));
|
||||
}
|
||||
|
||||
@@ -1011,13 +1011,13 @@ ParComplexLinearForm::ParallelAssemble()
|
||||
return tv;
|
||||
}
|
||||
|
||||
complex<double>
|
||||
complex<real_t>
|
||||
ParComplexLinearForm::operator()(const ParComplexGridFunction &gf) const
|
||||
{
|
||||
plfr->SyncMemory(*this);
|
||||
plfi->SyncMemory(*this);
|
||||
double s = (conv == ComplexOperator::HERMITIAN) ? 1.0 : -1.0;
|
||||
return complex<double>((*plfr)(gf.real()) - s * (*plfi)(gf.imag()),
|
||||
real_t s = (conv == ComplexOperator::HERMITIAN) ? 1.0 : -1.0;
|
||||
return complex<real_t>((*plfr)(gf.real()) - s * (*plfi)(gf.imag()),
|
||||
(*plfr)(gf.imag()) + s * (*plfi)(gf.real()));
|
||||
}
|
||||
|
||||
@@ -1255,7 +1255,7 @@ ParSesquilinearForm::FormLinearSystem(const Array<int> &ess_tdof_list,
|
||||
const int *d_ess_tdof_list =
|
||||
ess_tdof_list.GetMemory().Read(MemoryClass::DEVICE, n);
|
||||
const int *d_diag_i = Aih->diag->i;
|
||||
double *d_diag_data = Aih->diag->data;
|
||||
real_t *d_diag_data = Aih->diag->data;
|
||||
MFEM_GPU_FORALL(k, n,
|
||||
{
|
||||
const int j = d_ess_tdof_list[k];
|
||||
|
||||
+10
-10
@@ -45,7 +45,7 @@ public:
|
||||
void Update();
|
||||
|
||||
/// Assign constant values to the ComplexGridFunction data.
|
||||
ComplexGridFunction &operator=(const std::complex<double> & value)
|
||||
ComplexGridFunction &operator=(const std::complex<real_t> & value)
|
||||
{ *gfr = value.real(); *gfi = value.imag(); return *this; }
|
||||
|
||||
virtual void ProjectCoefficient(Coefficient &real_coeff,
|
||||
@@ -184,7 +184,7 @@ public:
|
||||
/// Assembles the linear form i.e. sums over all domain/bdr integrators.
|
||||
void Assemble();
|
||||
|
||||
std::complex<double> operator()(const ComplexGridFunction &gf) const;
|
||||
std::complex<real_t> operator()(const ComplexGridFunction &gf) const;
|
||||
};
|
||||
|
||||
|
||||
@@ -357,7 +357,7 @@ public:
|
||||
void Update();
|
||||
|
||||
/// Assign constant values to the ParComplexGridFunction data.
|
||||
ParComplexGridFunction &operator=(const std::complex<double> & value)
|
||||
ParComplexGridFunction &operator=(const std::complex<real_t> & value)
|
||||
{ *pgfr = value.real(); *pgfi = value.imag(); return *this; }
|
||||
|
||||
virtual void ProjectCoefficient(Coefficient &real_coeff,
|
||||
@@ -401,21 +401,21 @@ public:
|
||||
void SyncAlias() { pgfr->SyncAliasMemory(*this); pgfi->SyncAliasMemory(*this); }
|
||||
|
||||
|
||||
virtual double ComputeL2Error(Coefficient &exsolr, Coefficient &exsoli,
|
||||
virtual real_t ComputeL2Error(Coefficient &exsolr, Coefficient &exsoli,
|
||||
const IntegrationRule *irs[] = NULL) const
|
||||
{
|
||||
double err_r = pgfr->ComputeL2Error(exsolr, irs);
|
||||
double err_i = pgfi->ComputeL2Error(exsoli, irs);
|
||||
real_t err_r = pgfr->ComputeL2Error(exsolr, irs);
|
||||
real_t err_i = pgfi->ComputeL2Error(exsoli, irs);
|
||||
return sqrt(err_r * err_r + err_i * err_i);
|
||||
}
|
||||
|
||||
virtual double ComputeL2Error(VectorCoefficient &exsolr,
|
||||
virtual real_t ComputeL2Error(VectorCoefficient &exsolr,
|
||||
VectorCoefficient &exsoli,
|
||||
const IntegrationRule *irs[] = NULL,
|
||||
Array<int> *elems = NULL) const
|
||||
{
|
||||
double err_r = pgfr->ComputeL2Error(exsolr, irs, elems);
|
||||
double err_i = pgfi->ComputeL2Error(exsoli, irs, elems);
|
||||
real_t err_r = pgfr->ComputeL2Error(exsolr, irs, elems);
|
||||
real_t err_i = pgfi->ComputeL2Error(exsoli, irs, elems);
|
||||
return sqrt(err_r * err_r + err_i * err_i);
|
||||
}
|
||||
|
||||
@@ -535,7 +535,7 @@ public:
|
||||
/// Returns the vector assembled on the true dofs, i.e. P^t v.
|
||||
HypreParVector *ParallelAssemble();
|
||||
|
||||
std::complex<double> operator()(const ParComplexGridFunction &gf) const;
|
||||
std::complex<real_t> operator()(const ParComplexGridFunction &gf) const;
|
||||
|
||||
};
|
||||
|
||||
|
||||
+23
-23
@@ -24,11 +24,11 @@ void ConvergenceStudy::Reset()
|
||||
ndofs.SetSize(0);
|
||||
}
|
||||
|
||||
double ConvergenceStudy::GetNorm(GridFunction *gf, Coefficient *scalar_u,
|
||||
real_t ConvergenceStudy::GetNorm(GridFunction *gf, Coefficient *scalar_u,
|
||||
VectorCoefficient *vector_u)
|
||||
{
|
||||
bool norm_set = false;
|
||||
double norm=0.0;
|
||||
real_t norm=0.0;
|
||||
int order = gf->FESpace()->GetMaxElementOrder();
|
||||
int order_quad = std::max(2, 2*order+1);
|
||||
const IntegrationRule *irs[Geometry::NumGeom];
|
||||
@@ -87,7 +87,7 @@ void ConvergenceStudy::AddL2Error(GridFunction *gf,
|
||||
#endif
|
||||
if (!tdofs) { tdofs = gf->FESpace()->GetTrueVSize(); }
|
||||
ndofs.Append(tdofs);
|
||||
double L2Err = 1.;
|
||||
real_t L2Err = 1.;
|
||||
if (scalar_u)
|
||||
{
|
||||
L2Err = gf->ComputeL2Error(*scalar_u);
|
||||
@@ -105,11 +105,11 @@ void ConvergenceStudy::AddL2Error(GridFunction *gf,
|
||||
L2Errors.Append(L2Err);
|
||||
// Compute the rate of convergence by:
|
||||
// rate = log (||u - u_h|| / ||u - u_{h/2}||)/(1/dim * log(N_{h/2}/N_{h}))
|
||||
double val=0.;
|
||||
real_t val=0.;
|
||||
if (counter)
|
||||
{
|
||||
double num = log(L2Errors[counter-1]/L2Err);
|
||||
double den = log((double)ndofs[counter]/ndofs[counter-1]);
|
||||
real_t num = log(L2Errors[counter-1]/L2Err);
|
||||
real_t den = log((real_t)ndofs[counter]/ndofs[counter-1]);
|
||||
val = dim * num/den;
|
||||
}
|
||||
L2Rates.Append(val);
|
||||
@@ -132,19 +132,19 @@ void ConvergenceStudy::AddGf(GridFunction *gf, Coefficient *scalar_u,
|
||||
|
||||
if (grad)
|
||||
{
|
||||
double GradErr = gf->ComputeGradError(grad);
|
||||
real_t GradErr = gf->ComputeGradError(grad);
|
||||
DErrors.Append(GradErr);
|
||||
double error =
|
||||
real_t error =
|
||||
sqrt(L2Errors[counter-1]*L2Errors[counter-1]+GradErr*GradErr);
|
||||
EnErrors.Append(error);
|
||||
// Compute the rate of convergence by:
|
||||
// rate = log (||u - u_h|| / ||u - u_{h/2}||)/(1/dim * log(N_{h/2}/N_{h}))
|
||||
double val = 0.;
|
||||
double eval = 0.;
|
||||
real_t val = 0.;
|
||||
real_t eval = 0.;
|
||||
if (dcounter)
|
||||
{
|
||||
double num = log(DErrors[dcounter-1]/GradErr);
|
||||
double den = log((double)ndofs[dcounter]/ndofs[dcounter-1]);
|
||||
real_t num = log(DErrors[dcounter-1]/GradErr);
|
||||
real_t den = log((real_t)ndofs[dcounter]/ndofs[dcounter-1]);
|
||||
val = dim * num/den;
|
||||
num = log(EnErrors[dcounter-1]/error);
|
||||
eval = dim * num/den;
|
||||
@@ -159,15 +159,15 @@ void ConvergenceStudy::AddGf(GridFunction *gf, Coefficient *scalar_u,
|
||||
|
||||
if (cont_type == mfem::FiniteElementCollection::DISCONTINUOUS && ell_coeff)
|
||||
{
|
||||
double DGErr = gf->ComputeDGFaceJumpError(scalar_u,ell_coeff,jump_scaling);
|
||||
real_t DGErr = gf->ComputeDGFaceJumpError(scalar_u,ell_coeff,jump_scaling);
|
||||
DGFaceErrors.Append(DGErr);
|
||||
// Compute the rate of convergence by:
|
||||
// rate = log (||u - u_h|| / ||u - u_{h/2}||)/(1/dim * log(N_{h/2}/N_{h}))
|
||||
double val = 0.;
|
||||
real_t val = 0.;
|
||||
if (fcounter)
|
||||
{
|
||||
double num = log(DGFaceErrors[fcounter-1]/DGErr);
|
||||
double den = log((double)ndofs[fcounter]/ndofs[fcounter-1]);
|
||||
real_t num = log(DGFaceErrors[fcounter-1]/DGErr);
|
||||
real_t den = log((real_t)ndofs[fcounter]/ndofs[fcounter-1]);
|
||||
val = dim * num/den;
|
||||
}
|
||||
DGFaceRates.Append(val);
|
||||
@@ -183,7 +183,7 @@ void ConvergenceStudy::AddGf(GridFunction *gf, VectorCoefficient *vector_u,
|
||||
|
||||
AddL2Error(gf,nullptr,vector_u);
|
||||
int dim = gf->FESpace()->GetMesh()->Dimension();
|
||||
double DErr = 0.0;
|
||||
real_t DErr = 0.0;
|
||||
bool derivative = false;
|
||||
if (curl)
|
||||
{
|
||||
@@ -200,17 +200,17 @@ void ConvergenceStudy::AddGf(GridFunction *gf, VectorCoefficient *vector_u,
|
||||
}
|
||||
if (derivative)
|
||||
{
|
||||
double error = sqrt(L2Errors[counter-1]*L2Errors[counter-1] + DErr*DErr);
|
||||
real_t error = sqrt(L2Errors[counter-1]*L2Errors[counter-1] + DErr*DErr);
|
||||
DErrors.Append(DErr);
|
||||
EnErrors.Append(error);
|
||||
// Compute the rate of convergence by:
|
||||
// rate = log (||u - u_h|| / ||u - u_{h/2}||)/(1/dim * log(N_{h/2}/N_{h}))
|
||||
double val = 0.;
|
||||
double eval = 0.;
|
||||
real_t val = 0.;
|
||||
real_t eval = 0.;
|
||||
if (dcounter)
|
||||
{
|
||||
double num = log(DErrors[dcounter-1]/DErr);
|
||||
double den = log((double)ndofs[dcounter]/ndofs[dcounter-1]);
|
||||
real_t num = log(DErrors[dcounter-1]/DErr);
|
||||
real_t den = log((real_t)ndofs[dcounter]/ndofs[dcounter-1]);
|
||||
val = dim * num/den;
|
||||
num = log(EnErrors[dcounter-1]/error);
|
||||
eval = dim * num/den;
|
||||
@@ -238,7 +238,7 @@ void ConvergenceStudy::Print(bool relative, std::ostream &os)
|
||||
os << " -------------------------------------------"
|
||||
<< "\n";
|
||||
os << std::setprecision(4);
|
||||
double d = (relative) ? CoeffNorm : 1.0;
|
||||
real_t d = (relative) ? CoeffNorm : 1.0;
|
||||
for (int i =0; i<counter; i++)
|
||||
{
|
||||
os << std::right << std::setw(10)<< ndofs[i] << std::setw(16)
|
||||
|
||||
+11
-11
@@ -47,12 +47,12 @@ private:
|
||||
int print_flag=1;
|
||||
|
||||
// exact solution and derivatives
|
||||
double CoeffNorm;
|
||||
double CoeffDNorm;
|
||||
real_t CoeffNorm;
|
||||
real_t CoeffDNorm;
|
||||
|
||||
// Arrays to store error/rates
|
||||
Array<double> L2Errors, DGFaceErrors, DErrors, EnErrors;
|
||||
Array<double> L2Rates, DGFaceRates, DRates, EnRates;
|
||||
Array<real_t> L2Errors, DGFaceErrors, DErrors, EnErrors;
|
||||
Array<real_t> L2Rates, DGFaceRates, DRates, EnRates;
|
||||
Array<int> ndofs;
|
||||
|
||||
void AddL2Error(GridFunction *gf, Coefficient *scalar_u,
|
||||
@@ -64,7 +64,7 @@ private:
|
||||
void AddGf(GridFunction *gf, VectorCoefficient *vector_u,
|
||||
VectorCoefficient *curl, Coefficient *div);
|
||||
// returns the L2-norm of scalar_u or vector_u
|
||||
double GetNorm(GridFunction *gf, Coefficient *scalar_u,
|
||||
real_t GetNorm(GridFunction *gf, Coefficient *scalar_u,
|
||||
VectorCoefficient *vector_u);
|
||||
|
||||
public:
|
||||
@@ -104,40 +104,40 @@ public:
|
||||
}
|
||||
|
||||
/// Get the L2 error at step n
|
||||
double GetL2Error(int n)
|
||||
real_t GetL2Error(int n)
|
||||
{
|
||||
MFEM_VERIFY( n <= counter,"Step out of bounds")
|
||||
return L2Errors[n];
|
||||
}
|
||||
|
||||
/// Get all L2 errors
|
||||
void GetL2Errors(Array<double> & L2Errors_)
|
||||
void GetL2Errors(Array<real_t> & L2Errors_)
|
||||
{
|
||||
L2Errors_ = L2Errors;
|
||||
}
|
||||
|
||||
/// Get the Grad/Curl/Div error at step n
|
||||
double GetDError(int n)
|
||||
real_t GetDError(int n)
|
||||
{
|
||||
MFEM_VERIFY(n <= dcounter,"Step out of bounds")
|
||||
return DErrors[n];
|
||||
}
|
||||
|
||||
/// Get all Grad/Curl/Div errors
|
||||
void GetDErrors(Array<double> & DErrors_)
|
||||
void GetDErrors(Array<real_t> & DErrors_)
|
||||
{
|
||||
DErrors_ = DErrors;
|
||||
}
|
||||
|
||||
/// Get the DGFaceJumps error at step n
|
||||
double GetDGFaceJumpsError(int n)
|
||||
real_t GetDGFaceJumpsError(int n)
|
||||
{
|
||||
MFEM_VERIFY(n<= fcounter,"Step out of bounds")
|
||||
return DGFaceErrors[n];
|
||||
}
|
||||
|
||||
/// Get all DGFaceJumps errors
|
||||
void GetDGFaceJumpsErrors(Array<double> & DGFaceErrors_)
|
||||
void GetDGFaceJumpsErrors(Array<real_t> & DGFaceErrors_)
|
||||
{
|
||||
DGFaceErrors_ = DGFaceErrors;
|
||||
}
|
||||
|
||||
@@ -176,10 +176,10 @@ protected:
|
||||
/** When cycle >= 0, it is appended to directory names. */
|
||||
int cycle;
|
||||
/// Physical time (for time-dependent simulations)
|
||||
double time;
|
||||
real_t time;
|
||||
|
||||
/// Time step i.e. delta_t (for time-dependent simulations)
|
||||
double time_step;
|
||||
real_t time_step;
|
||||
|
||||
/// Serial or parallel run? False iff mesh is a ParMesh
|
||||
bool serial;
|
||||
@@ -318,17 +318,17 @@ public:
|
||||
/// Set time cycle (for time-dependent simulations)
|
||||
void SetCycle(int c) { cycle = c; }
|
||||
/// Set physical time (for time-dependent simulations)
|
||||
void SetTime(double t) { time = t; }
|
||||
void SetTime(real_t t) { time = t; }
|
||||
|
||||
/// Set the simulation time step (for time-dependent simulations)
|
||||
void SetTimeStep(double ts) { time_step = ts; }
|
||||
void SetTimeStep(real_t ts) { time_step = ts; }
|
||||
|
||||
/// Get time cycle (for time-dependent simulations)
|
||||
int GetCycle() const { return cycle; }
|
||||
/// Get physical time (for time-dependent simulations)
|
||||
double GetTime() const { return time; }
|
||||
real_t GetTime() const { return time; }
|
||||
/// Get the simulation time step (for time-dependent simulations)
|
||||
double GetTimeStep() const { return time_step; }
|
||||
real_t GetTimeStep() const { return time_step; }
|
||||
|
||||
/// Get the name of the collection
|
||||
const std::string& GetCollectionName() const { return name; }
|
||||
|
||||
+19
-19
@@ -45,7 +45,7 @@ DGMassInverse::DGMassInverse(FiniteElementSpace &fes_orig, Coefficient *coeff,
|
||||
d2q = &fes_orig.GetFE(0)->GetDofToQuad(fes.GetFE(0)->GetNodes(), mode);
|
||||
|
||||
int n = d2q->ndof;
|
||||
Array<double> B_inv = d2q->B; // deep copy
|
||||
Array<real_t> B_inv = d2q->B; // deep copy
|
||||
Array<int> ipiv(n);
|
||||
// solver basis to original
|
||||
LUFactors lu(B_inv.HostReadWrite(), ipiv.HostWrite());
|
||||
@@ -97,11 +97,11 @@ void DGMassInverse::SetOperator(const Operator &op)
|
||||
MFEM_ABORT("SetOperator not supported with DGMassInverse.")
|
||||
}
|
||||
|
||||
void DGMassInverse::SetRelTol(const double rel_tol_) { rel_tol = rel_tol_; }
|
||||
void DGMassInverse::SetRelTol(const real_t rel_tol_) { rel_tol = rel_tol_; }
|
||||
|
||||
void DGMassInverse::SetAbsTol(const double abs_tol_) { abs_tol = abs_tol_; }
|
||||
void DGMassInverse::SetAbsTol(const real_t abs_tol_) { abs_tol = abs_tol_; }
|
||||
|
||||
void DGMassInverse::SetMaxIter(const double max_iter_) { max_iter = max_iter_; }
|
||||
void DGMassInverse::SetMaxIter(const real_t max_iter_) { max_iter = max_iter_; }
|
||||
|
||||
void DGMassInverse::Update()
|
||||
{
|
||||
@@ -135,22 +135,22 @@ void DGMassInverse::DGMassCGIteration(const Vector &b_, Vector &u_) const
|
||||
auto z = z_.Write();
|
||||
auto u = u_.ReadWrite();
|
||||
|
||||
const double RELTOL = rel_tol;
|
||||
const double ABSTOL = abs_tol;
|
||||
const double MAXIT = max_iter;
|
||||
const real_t RELTOL = rel_tol;
|
||||
const real_t ABSTOL = abs_tol;
|
||||
const real_t MAXIT = max_iter;
|
||||
const bool IT_MODE = iterative_mode;
|
||||
const bool CHANGE_BASIS = (d2q != nullptr);
|
||||
|
||||
// b is the right-hand side (if no change of basis, this just points to the
|
||||
// incoming RHS vector, if we have to change basis, this points to the
|
||||
// internal b2 vector where we put the transformed RHS)
|
||||
const double *b;
|
||||
const real_t *b;
|
||||
// the following are non-null if we have to change basis
|
||||
double *b2 = nullptr; // non-const access to b2
|
||||
const double *b_orig = nullptr; // RHS vector in "original" basis
|
||||
const double *d2q_B = nullptr; // matrix to transform initial guess
|
||||
const double *q2d_B = nullptr; // matrix to transform solution
|
||||
const double *q2d_Bt = nullptr; // matrix to transform RHS
|
||||
real_t *b2 = nullptr; // non-const access to b2
|
||||
const real_t *b_orig = nullptr; // RHS vector in "original" basis
|
||||
const real_t *d2q_B = nullptr; // matrix to transform initial guess
|
||||
const real_t *q2d_B = nullptr; // matrix to transform solution
|
||||
const real_t *q2d_Bt = nullptr; // matrix to transform RHS
|
||||
if (CHANGE_BASIS)
|
||||
{
|
||||
d2q_B = d2q->B.Read();
|
||||
@@ -210,13 +210,13 @@ void DGMassInverse::DGMassCGIteration(const Vector &b_, Vector &u_) const
|
||||
DGMassPreconditioner(e, NE, ND, dinv, r, z);
|
||||
DGMassAxpy(e, NE, ND, 1.0, z, 0.0, z, d); // d = z
|
||||
|
||||
double nom = DGMassDot<NB>(e, NE, ND, d, r);
|
||||
real_t nom = DGMassDot<NB>(e, NE, ND, d, r);
|
||||
if (nom < 0.0) { return; /* Not positive definite */ }
|
||||
double r0 = fmax(nom*RELTOL*RELTOL, ABSTOL*ABSTOL);
|
||||
real_t r0 = fmax(nom*RELTOL*RELTOL, ABSTOL*ABSTOL);
|
||||
if (nom <= r0) { return; /* Converged */ }
|
||||
|
||||
DGMassApply<DIM,D1D,Q1D>(e, NE, B, Bt, pa_data, d, z, d1d, q1d);
|
||||
double den = DGMassDot<NB>(e, NE, ND, z, d);
|
||||
real_t den = DGMassDot<NB>(e, NE, ND, z, d);
|
||||
if (den <= 0.0)
|
||||
{
|
||||
DGMassDot<NB>(e, NE, ND, d, d);
|
||||
@@ -228,19 +228,19 @@ void DGMassInverse::DGMassCGIteration(const Vector &b_, Vector &u_) const
|
||||
int i = 1;
|
||||
while (true)
|
||||
{
|
||||
const double alpha = nom/den;
|
||||
const real_t alpha = nom/den;
|
||||
DGMassAxpy(e, NE, ND, 1.0, u, alpha, d, u); // u = u + alpha*d
|
||||
DGMassAxpy(e, NE, ND, 1.0, r, -alpha, z, r); // r = r - alpha*A*d
|
||||
|
||||
DGMassPreconditioner(e, NE, ND, dinv, r, z);
|
||||
|
||||
double betanom = DGMassDot<NB>(e, NE, ND, r, z);
|
||||
real_t betanom = DGMassDot<NB>(e, NE, ND, r, z);
|
||||
if (betanom < 0.0) { return; /* Not positive definite */ }
|
||||
if (betanom <= r0) { break; /* Converged */ }
|
||||
|
||||
if (++i > MAXIT) { break; }
|
||||
|
||||
const double beta = betanom/nom;
|
||||
const real_t beta = betanom/nom;
|
||||
DGMassAxpy(e, NE, ND, 1.0, z, beta, d, d); // d = z + beta*d
|
||||
DGMassApply<DIM,D1D,Q1D>(e, NE, B, Bt, pa_data, d, z, d1d, q1d); // z = A d
|
||||
den = DGMassDot<NB>(e, NE, ND, d, z);
|
||||
|
||||
+7
-7
@@ -30,13 +30,13 @@ protected:
|
||||
DG_FECollection fec; ///< FE collection in requested basis.
|
||||
FiniteElementSpace fes; ///< FE space in requested basis.
|
||||
const DofToQuad *d2q; ///< Change of basis. Not owned.
|
||||
Array<double> B_; ///< Inverse of change of basis.
|
||||
Array<double> Bt_; ///< Inverse of change of basis, transposed.
|
||||
Array<real_t> B_; ///< Inverse of change of basis.
|
||||
Array<real_t> Bt_; ///< Inverse of change of basis, transposed.
|
||||
class BilinearForm *M; ///< Mass bilinear form, owned.
|
||||
class MassIntegrator *m; ///< Mass integrator, owned by the form @ref M.
|
||||
Vector diag_inv; ///< Jacobi preconditioner.
|
||||
double rel_tol = 1e-12; ///< Relative CG tolerance.
|
||||
double abs_tol = 1e-12; ///< Absolute CG tolerance.
|
||||
real_t rel_tol = 1e-12; ///< Relative CG tolerance.
|
||||
real_t abs_tol = 1e-12; ///< Absolute CG tolerance.
|
||||
int max_iter = 100; ///< Maximum number of CG iterations;
|
||||
|
||||
/// @name Intermediate vectors needed for CG three-term recurrence.
|
||||
@@ -92,11 +92,11 @@ public:
|
||||
/// Not implemented. Aborts.
|
||||
void SetOperator(const Operator &op);
|
||||
/// Set the relative tolerance.
|
||||
void SetRelTol(const double rel_tol_);
|
||||
void SetRelTol(const real_t rel_tol_);
|
||||
/// Set the absolute tolerance.
|
||||
void SetAbsTol(const double abs_tol_);
|
||||
void SetAbsTol(const real_t abs_tol_);
|
||||
/// Set the maximum number of iterations.
|
||||
void SetMaxIter(const double max_iter_);
|
||||
void SetMaxIter(const real_t max_iter_);
|
||||
/// Recompute operator and preconditioner (when coefficient or mesh changes).
|
||||
void Update();
|
||||
|
||||
|
||||
+32
-32
@@ -26,11 +26,11 @@ template <int DIM, int D1D, int Q1D>
|
||||
MFEM_HOST_DEVICE inline
|
||||
void DGMassApply(const int e,
|
||||
const int NE,
|
||||
const double *B,
|
||||
const double *Bt,
|
||||
const double *pa_data,
|
||||
const double *x,
|
||||
double *y,
|
||||
const real_t *B,
|
||||
const real_t *Bt,
|
||||
const real_t *pa_data,
|
||||
const real_t *x,
|
||||
real_t *y,
|
||||
const int d1d = 0,
|
||||
const int q1d = 0)
|
||||
{
|
||||
@@ -77,9 +77,9 @@ MFEM_HOST_DEVICE inline
|
||||
void DGMassPreconditioner(const int e,
|
||||
const int NE,
|
||||
const int ND,
|
||||
const double *dinv,
|
||||
const double *x,
|
||||
double *y)
|
||||
const real_t *dinv,
|
||||
const real_t *x,
|
||||
real_t *y)
|
||||
{
|
||||
const auto X = ConstDeviceMatrix(x, ND, NE);
|
||||
const auto D = ConstDeviceMatrix(dinv, ND, NE);
|
||||
@@ -99,11 +99,11 @@ MFEM_HOST_DEVICE inline
|
||||
void DGMassAxpy(const int e,
|
||||
const int NE,
|
||||
const int ND,
|
||||
const double a,
|
||||
const double *x,
|
||||
const double b,
|
||||
const double *y,
|
||||
double *z)
|
||||
const real_t a,
|
||||
const real_t *x,
|
||||
const real_t b,
|
||||
const real_t *y,
|
||||
real_t *z)
|
||||
{
|
||||
const auto X = ConstDeviceMatrix(x, ND, NE);
|
||||
const auto Y = ConstDeviceMatrix(y, ND, NE);
|
||||
@@ -121,11 +121,11 @@ void DGMassAxpy(const int e,
|
||||
|
||||
template <int NB>
|
||||
MFEM_HOST_DEVICE inline
|
||||
double DGMassDot(const int e,
|
||||
real_t DGMassDot(const int e,
|
||||
const int NE,
|
||||
const int ND,
|
||||
const double *x,
|
||||
const double *y)
|
||||
const real_t *x,
|
||||
const real_t *y)
|
||||
{
|
||||
const auto X = ConstDeviceMatrix(x, ND, NE);
|
||||
const auto Y = ConstDeviceMatrix(y, ND, NE);
|
||||
@@ -133,7 +133,7 @@ double DGMassDot(const int e,
|
||||
const int tid = MFEM_THREAD_ID(x) + MFEM_THREAD_SIZE(x)*MFEM_THREAD_ID(y);
|
||||
const int bxy = MFEM_THREAD_SIZE(x)*MFEM_THREAD_SIZE(y);
|
||||
|
||||
MFEM_SHARED double s_dot[NB*NB];
|
||||
MFEM_SHARED real_t s_dot[NB*NB];
|
||||
s_dot[tid] = 0.0;
|
||||
|
||||
for (int i = tid; i < ND; i += bxy) { s_dot[tid] += X(i,e)*Y(i,e); }
|
||||
@@ -176,9 +176,9 @@ template<int T_D1D = 0>
|
||||
MFEM_HOST_DEVICE inline
|
||||
void DGMassBasis2D(const int e,
|
||||
const int NE,
|
||||
const double *b_,
|
||||
const double *x_,
|
||||
double *y_,
|
||||
const real_t *b_,
|
||||
const real_t *x_,
|
||||
real_t *y_,
|
||||
const int d1d = 0)
|
||||
{
|
||||
constexpr int MD1 = T_D1D ? T_D1D : DofQuadLimits::MAX_D1D;
|
||||
@@ -188,9 +188,9 @@ void DGMassBasis2D(const int e,
|
||||
const auto x = Reshape(x_, D1D, D1D, NE);
|
||||
auto y = Reshape(y_, D1D, D1D, NE);
|
||||
|
||||
MFEM_SHARED double sB[MD1*MD1];
|
||||
MFEM_SHARED double sm0[MD1*MD1];
|
||||
MFEM_SHARED double sm1[MD1*MD1];
|
||||
MFEM_SHARED real_t sB[MD1*MD1];
|
||||
MFEM_SHARED real_t sm0[MD1*MD1];
|
||||
MFEM_SHARED real_t sm1[MD1*MD1];
|
||||
|
||||
kernels::internal::LoadB<MD1,MD1>(D1D,D1D,b,sB);
|
||||
|
||||
@@ -217,9 +217,9 @@ template<int T_D1D = 0>
|
||||
MFEM_HOST_DEVICE inline
|
||||
void DGMassBasis3D(const int e,
|
||||
const int NE,
|
||||
const double *b_,
|
||||
const double *x_,
|
||||
double *y_,
|
||||
const real_t *b_,
|
||||
const real_t *x_,
|
||||
real_t *y_,
|
||||
const int d1d = 0)
|
||||
{
|
||||
const int D1D = T_D1D ? T_D1D : d1d;
|
||||
@@ -230,9 +230,9 @@ void DGMassBasis3D(const int e,
|
||||
|
||||
constexpr int MD1 = T_D1D ? T_D1D : DofQuadLimits::MAX_D1D;
|
||||
|
||||
MFEM_SHARED double sB[MD1*MD1];
|
||||
MFEM_SHARED double sm0[MD1*MD1*MD1];
|
||||
MFEM_SHARED double sm1[MD1*MD1*MD1];
|
||||
MFEM_SHARED real_t sB[MD1*MD1];
|
||||
MFEM_SHARED real_t sm0[MD1*MD1*MD1];
|
||||
MFEM_SHARED real_t sm1[MD1*MD1*MD1];
|
||||
|
||||
kernels::internal::LoadB<MD1,MD1>(D1D,D1D,b,sB);
|
||||
|
||||
@@ -264,9 +264,9 @@ template<int DIM, int T_D1D = 0>
|
||||
MFEM_HOST_DEVICE inline
|
||||
void DGMassBasis(const int e,
|
||||
const int NE,
|
||||
const double *b_,
|
||||
const double *x_,
|
||||
double *y_,
|
||||
const real_t *b_,
|
||||
const real_t *x_,
|
||||
real_t *y_,
|
||||
const int d1d = 0)
|
||||
{
|
||||
if (DIM == 2)
|
||||
|
||||
+20
-20
@@ -14,7 +14,7 @@
|
||||
namespace mfem
|
||||
{
|
||||
|
||||
void DofTransformation::TransformPrimal(double *v) const
|
||||
void DofTransformation::TransformPrimal(real_t *v) const
|
||||
{
|
||||
MFEM_ASSERT(dof_trans_,
|
||||
"DofTransformation has no local transformation, call "
|
||||
@@ -46,7 +46,7 @@ void DofTransformation::TransformPrimal(double *v) const
|
||||
}
|
||||
}
|
||||
|
||||
void DofTransformation::InvTransformPrimal(double *v) const
|
||||
void DofTransformation::InvTransformPrimal(real_t *v) const
|
||||
{
|
||||
MFEM_ASSERT(dof_trans_,
|
||||
"DofTransformation has no local transformation, call "
|
||||
@@ -78,7 +78,7 @@ void DofTransformation::InvTransformPrimal(double *v) const
|
||||
}
|
||||
}
|
||||
|
||||
void DofTransformation::TransformDual(double *v) const
|
||||
void DofTransformation::TransformDual(real_t *v) const
|
||||
{
|
||||
MFEM_ASSERT(dof_trans_,
|
||||
"DofTransformation has no local transformation, call "
|
||||
@@ -110,7 +110,7 @@ void DofTransformation::TransformDual(double *v) const
|
||||
}
|
||||
}
|
||||
|
||||
void DofTransformation::InvTransformDual(double *v) const
|
||||
void DofTransformation::InvTransformDual(real_t *v) const
|
||||
{
|
||||
MFEM_ASSERT(dof_trans_,
|
||||
"DofTransformation has no local transformation, call "
|
||||
@@ -173,7 +173,7 @@ void TransformDual(const DofTransformation *ran_dof_trans,
|
||||
}
|
||||
|
||||
// ordering (i0j0, i1j0, i0j1, i1j1), each row is a column major matrix
|
||||
const double ND_DofTransformation::T_data[24] =
|
||||
const real_t ND_DofTransformation::T_data[24] =
|
||||
{
|
||||
1.0, 0.0, 0.0, 1.0,
|
||||
-1.0, -1.0, 0.0, 1.0,
|
||||
@@ -184,10 +184,10 @@ const double ND_DofTransformation::T_data[24] =
|
||||
};
|
||||
|
||||
const DenseTensor ND_DofTransformation
|
||||
::T(const_cast<double *>(ND_DofTransformation::T_data), 2, 2, 6);
|
||||
::T(const_cast<real_t *>(ND_DofTransformation::T_data), 2, 2, 6);
|
||||
|
||||
// ordering (i0j0, i1j0, i0j1, i1j1), each row is a column major matrix
|
||||
const double ND_DofTransformation::TInv_data[24] =
|
||||
const real_t ND_DofTransformation::TInv_data[24] =
|
||||
{
|
||||
1.0, 0.0, 0.0, 1.0,
|
||||
-1.0, -1.0, 0.0, 1.0,
|
||||
@@ -198,7 +198,7 @@ const double ND_DofTransformation::TInv_data[24] =
|
||||
};
|
||||
|
||||
const DenseTensor ND_DofTransformation
|
||||
::TInv(const_cast<double *>(TInv_data), 2, 2, 6);
|
||||
::TInv(const_cast<real_t *>(TInv_data), 2, 2, 6);
|
||||
|
||||
ND_DofTransformation::ND_DofTransformation(int size, int p, int num_edges,
|
||||
int num_tri_faces)
|
||||
@@ -212,7 +212,7 @@ ND_DofTransformation::ND_DofTransformation(int size, int p, int num_edges,
|
||||
}
|
||||
|
||||
void ND_DofTransformation::TransformPrimal(const Array<int> & Fo,
|
||||
double *v) const
|
||||
real_t *v) const
|
||||
{
|
||||
// Return immediately when no face DoFs are present
|
||||
if (IsIdentity()) { return; }
|
||||
@@ -221,7 +221,7 @@ void ND_DofTransformation::TransformPrimal(const Array<int> & Fo,
|
||||
"Face orientation array is shorter than the number of faces in "
|
||||
"ND_DofTransformation");
|
||||
|
||||
double data[2];
|
||||
real_t data[2];
|
||||
Vector v2(data, 2);
|
||||
DenseMatrix T2;
|
||||
|
||||
@@ -231,14 +231,14 @@ void ND_DofTransformation::TransformPrimal(const Array<int> & Fo,
|
||||
for (int i=0; i<nfdofs/2; i++)
|
||||
{
|
||||
v2 = &v[nedges*nedofs + f*nfdofs + 2*i];
|
||||
T2.UseExternalData(const_cast<double *>(T.GetData(Fo[f])), 2, 2);
|
||||
T2.UseExternalData(const_cast<real_t *>(T.GetData(Fo[f])), 2, 2);
|
||||
T2.Mult(v2, &v[nedges*nedofs + f*nfdofs + 2*i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ND_DofTransformation::InvTransformPrimal(const Array<int> & Fo,
|
||||
double *v) const
|
||||
real_t *v) const
|
||||
{
|
||||
// Return immediately when no face DoFs are present
|
||||
if (IsIdentity()) { return; }
|
||||
@@ -247,7 +247,7 @@ void ND_DofTransformation::InvTransformPrimal(const Array<int> & Fo,
|
||||
"Face orientation array is shorter than the number of faces in "
|
||||
"ND_DofTransformation");
|
||||
|
||||
double data[2];
|
||||
real_t data[2];
|
||||
Vector v2(data, 2);
|
||||
DenseMatrix T2Inv;
|
||||
|
||||
@@ -257,13 +257,13 @@ void ND_DofTransformation::InvTransformPrimal(const Array<int> & Fo,
|
||||
for (int i=0; i<nfdofs/2; i++)
|
||||
{
|
||||
v2 = &v[nedges*nedofs + f*nfdofs + 2*i];
|
||||
T2Inv.UseExternalData(const_cast<double *>(TInv.GetData(Fo[f])), 2, 2);
|
||||
T2Inv.UseExternalData(const_cast<real_t *>(TInv.GetData(Fo[f])), 2, 2);
|
||||
T2Inv.Mult(v2, &v[nedges*nedofs + f*nfdofs + 2*i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ND_DofTransformation::TransformDual(const Array<int> & Fo, double *v) const
|
||||
void ND_DofTransformation::TransformDual(const Array<int> & Fo, real_t *v) const
|
||||
{
|
||||
// Return immediately when no face DoFs are present
|
||||
if (IsIdentity()) { return; }
|
||||
@@ -272,7 +272,7 @@ void ND_DofTransformation::TransformDual(const Array<int> & Fo, double *v) const
|
||||
"Face orientation array is shorter than the number of faces in "
|
||||
"ND_DofTransformation");
|
||||
|
||||
double data[2];
|
||||
real_t data[2];
|
||||
Vector v2(data, 2);
|
||||
DenseMatrix T2Inv;
|
||||
|
||||
@@ -282,14 +282,14 @@ void ND_DofTransformation::TransformDual(const Array<int> & Fo, double *v) const
|
||||
for (int i=0; i<nfdofs/2; i++)
|
||||
{
|
||||
v2 = &v[nedges*nedofs + f*nfdofs + 2*i];
|
||||
T2Inv.UseExternalData(const_cast<double *>(TInv.GetData(Fo[f])), 2, 2);
|
||||
T2Inv.UseExternalData(const_cast<real_t *>(TInv.GetData(Fo[f])), 2, 2);
|
||||
T2Inv.MultTranspose(v2, &v[nedges*nedofs + f*nfdofs + 2*i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ND_DofTransformation::InvTransformDual(const Array<int> & Fo,
|
||||
double *v) const
|
||||
real_t *v) const
|
||||
{
|
||||
// Return immediately when no face DoFs are present
|
||||
if (IsIdentity()) { return; }
|
||||
@@ -298,7 +298,7 @@ void ND_DofTransformation::InvTransformDual(const Array<int> & Fo,
|
||||
"Face orientation array is shorter than the number of faces in "
|
||||
"ND_DofTransformation");
|
||||
|
||||
double data[2];
|
||||
real_t data[2];
|
||||
Vector v2(data, 2);
|
||||
DenseMatrix T2;
|
||||
|
||||
@@ -308,7 +308,7 @@ void ND_DofTransformation::InvTransformDual(const Array<int> & Fo,
|
||||
for (int i=0; i<nfdofs/2; i++)
|
||||
{
|
||||
v2 = &v[nedges*nedofs + f*nfdofs + 2*i];
|
||||
T2.UseExternalData(const_cast<double *>(T.GetData(Fo[f])), 2, 2);
|
||||
T2.UseExternalData(const_cast<real_t *>(T.GetData(Fo[f])), 2, 2);
|
||||
T2.MultTranspose(v2, &v[nedges*nedofs + f*nfdofs + 2*i]);
|
||||
}
|
||||
}
|
||||
|
||||
+14
-14
@@ -88,7 +88,7 @@ public:
|
||||
FiniteElement::Project() to the transformed vector stored within a
|
||||
GridFunction object. */
|
||||
virtual void TransformPrimal(const Array<int> & face_orientation,
|
||||
double *v) const = 0;
|
||||
real_t *v) const = 0;
|
||||
inline void TransformPrimal(const Array<int> & face_orientation,
|
||||
Vector &v) const
|
||||
{ TransformPrimal(face_orientation, v.GetData()); }
|
||||
@@ -99,7 +99,7 @@ public:
|
||||
can be used to compute a local interpolation.
|
||||
*/
|
||||
virtual void InvTransformPrimal(const Array<int> & face_orientation,
|
||||
double *v) const = 0;
|
||||
real_t *v) const = 0;
|
||||
inline void InvTransformPrimal(const Array<int> & face_orientation,
|
||||
Vector &v) const
|
||||
{ InvTransformPrimal(face_orientation, v.GetData()); }
|
||||
@@ -107,14 +107,14 @@ public:
|
||||
/** Transform dual DoFs as computed by a LinearFormIntegrator before summing
|
||||
into a LinearForm object. */
|
||||
virtual void TransformDual(const Array<int> & face_orientation,
|
||||
double *v) const = 0;
|
||||
real_t *v) const = 0;
|
||||
inline void TransformDual(const Array<int> & face_orientation,
|
||||
Vector &v) const
|
||||
{ TransformDual(face_orientation, v.GetData()); }
|
||||
|
||||
/** Inverse Transform dual DoFs */
|
||||
virtual void InvTransformDual(const Array<int> & face_orientation,
|
||||
double *v) const = 0;
|
||||
real_t *v) const = 0;
|
||||
inline void InvTransformDual(const Array<int> & face_orientation,
|
||||
Vector &v) const
|
||||
{ InvTransformDual(face_orientation, v.GetData()); }
|
||||
@@ -207,7 +207,7 @@ public:
|
||||
transformation can be used to map the local vector computed by
|
||||
FiniteElement::Project() to the transformed vector stored within a
|
||||
GridFunction object. */
|
||||
void TransformPrimal(double *v) const;
|
||||
void TransformPrimal(real_t *v) const;
|
||||
inline void TransformPrimal(Vector &v) const
|
||||
{ TransformPrimal(v.GetData()); }
|
||||
|
||||
@@ -225,18 +225,18 @@ public:
|
||||
transform the vector obtained using GridFunction::GetSubVector before it
|
||||
can be used to compute a local interpolation.
|
||||
*/
|
||||
void InvTransformPrimal(double *v) const;
|
||||
void InvTransformPrimal(real_t *v) const;
|
||||
inline void InvTransformPrimal(Vector &v) const
|
||||
{ InvTransformPrimal(v.GetData()); }
|
||||
|
||||
/** Transform dual DoFs as computed by a LinearFormIntegrator before summing
|
||||
into a LinearForm object. */
|
||||
void TransformDual(double *v) const;
|
||||
void TransformDual(real_t *v) const;
|
||||
inline void TransformDual(Vector &v) const
|
||||
{ TransformDual(v.GetData()); }
|
||||
|
||||
/** Inverse Transform dual DoFs */
|
||||
void InvTransformDual(double *v) const;
|
||||
void InvTransformDual(real_t *v) const;
|
||||
inline void InvTransformDual(Vector &v) const
|
||||
{ InvTransformDual(v.GetData()); }
|
||||
|
||||
@@ -301,8 +301,8 @@ void TransformDual(const DofTransformation *ran_dof_trans,
|
||||
class ND_DofTransformation : public StatelessDofTransformation
|
||||
{
|
||||
private:
|
||||
static const double T_data[24];
|
||||
static const double TInv_data[24];
|
||||
static const real_t T_data[24];
|
||||
static const real_t TInv_data[24];
|
||||
static const DenseTensor T, TInv;
|
||||
|
||||
protected:
|
||||
@@ -324,10 +324,10 @@ public:
|
||||
|
||||
bool IsIdentity() const override { return nfdofs < 2; }
|
||||
|
||||
void TransformPrimal(const Array<int> & Fo, double *v) const override;
|
||||
void InvTransformPrimal(const Array<int> & Fo, double *v) const override;
|
||||
void TransformDual(const Array<int> & Fo, double *v) const override;
|
||||
void InvTransformDual(const Array<int> & Fo, double *v) const override;
|
||||
void TransformPrimal(const Array<int> & Fo, real_t *v) const override;
|
||||
void InvTransformPrimal(const Array<int> & Fo, real_t *v) const override;
|
||||
void TransformDual(const Array<int> & Fo, real_t *v) const override;
|
||||
void InvTransformDual(const Array<int> & Fo, real_t *v) const override;
|
||||
};
|
||||
|
||||
/// Stateless DoF transformation implementation for the Nedelec basis on
|
||||
|
||||
+17
-17
@@ -25,7 +25,7 @@ ElementTransformation::ElementTransformation()
|
||||
mesh(nullptr)
|
||||
{ }
|
||||
|
||||
double ElementTransformation::EvalWeight()
|
||||
real_t ElementTransformation::EvalWeight()
|
||||
{
|
||||
MFEM_ASSERT((EvalState & WEIGHT_MASK) == 0, "");
|
||||
Jacobian();
|
||||
@@ -78,13 +78,13 @@ int InverseElementTransformation::FindClosestPhysPoint(
|
||||
|
||||
// Initialize distance and index of closest point
|
||||
int minIndex = -1;
|
||||
double minDist = std::numeric_limits<double>::max();
|
||||
real_t minDist = std::numeric_limits<real_t>::max();
|
||||
|
||||
// Check all integration points in ir
|
||||
const int npts = ir.GetNPoints();
|
||||
for (int i = 0; i < npts; ++i)
|
||||
{
|
||||
double dist = pt.DistanceTo(physPts.GetColumn(i));
|
||||
real_t dist = pt.DistanceTo(physPts.GetColumn(i));
|
||||
if (dist < minDist)
|
||||
{
|
||||
minDist = dist;
|
||||
@@ -102,7 +102,7 @@ int InverseElementTransformation::FindClosestRefPoint(
|
||||
|
||||
// Initialize distance and index of closest point
|
||||
int minIndex = -1;
|
||||
double minDist = std::numeric_limits<double>::max();
|
||||
real_t minDist = std::numeric_limits<real_t>::max();
|
||||
|
||||
// Check all integration points in ir using the local metric at each point
|
||||
// induced by the transformation.
|
||||
@@ -115,7 +115,7 @@ int InverseElementTransformation::FindClosestRefPoint(
|
||||
dp -= pt;
|
||||
T->SetIntPoint(&ip);
|
||||
T->InverseJacobian().Mult(dp, dr);
|
||||
double dist = dr.Norml2();
|
||||
real_t dist = dr.Norml2();
|
||||
// double dist = dr.Normlinf();
|
||||
if (dist < minDist)
|
||||
{
|
||||
@@ -126,7 +126,7 @@ int InverseElementTransformation::FindClosestRefPoint(
|
||||
return minIndex;
|
||||
}
|
||||
|
||||
void InverseElementTransformation::NewtonPrint(int mode, double val)
|
||||
void InverseElementTransformation::NewtonPrint(int mode, real_t val)
|
||||
{
|
||||
std::ostream &os = mfem::out;
|
||||
|
||||
@@ -174,13 +174,13 @@ int InverseElementTransformation::NewtonSolve(const Vector &pt,
|
||||
{
|
||||
MFEM_ASSERT(pt.Size() == T->GetSpaceDim(), "invalid point");
|
||||
|
||||
const double phys_tol = phys_rtol*pt.Normlinf();
|
||||
const real_t phys_tol = phys_rtol*pt.Normlinf();
|
||||
|
||||
const int geom = T->GetGeometryType();
|
||||
const int dim = T->GetDimension();
|
||||
const int sdim = T->GetSpaceDim();
|
||||
IntegrationPoint xip, prev_xip;
|
||||
double xd[3], yd[3], dxd[3], dx_norm = -1.0, err_phys, real_dx_norm = -1.0;
|
||||
real_t xd[3], yd[3], dxd[3], dx_norm = -1.0, err_phys, real_dx_norm = -1.0;
|
||||
Vector x(xd, dim), y(yd, sdim), dx(dxd, dim);
|
||||
bool hit_bdr = false, prev_hit_bdr = false;
|
||||
|
||||
@@ -225,7 +225,7 @@ int InverseElementTransformation::NewtonSolve(const Vector &pt,
|
||||
{
|
||||
if (print_level >= 1)
|
||||
{
|
||||
NewtonPrint(1, (double)it);
|
||||
NewtonPrint(1, (real_t)it);
|
||||
NewtonPrint(3, dx_norm);
|
||||
NewtonPrint(30, err_phys);
|
||||
}
|
||||
@@ -237,7 +237,7 @@ int InverseElementTransformation::NewtonSolve(const Vector &pt,
|
||||
{
|
||||
if (it == 0 || print_level >= 2)
|
||||
{
|
||||
NewtonPrint(1, (double)it);
|
||||
NewtonPrint(1, (real_t)it);
|
||||
NewtonPrint(3, dx_norm);
|
||||
NewtonPrint(18, err_phys);
|
||||
}
|
||||
@@ -261,7 +261,7 @@ int InverseElementTransformation::NewtonSolve(const Vector &pt,
|
||||
{
|
||||
if (print_level <= 1)
|
||||
{
|
||||
NewtonPrint(1, (double)it);
|
||||
NewtonPrint(1, (real_t)it);
|
||||
NewtonPrint(3, dx_norm);
|
||||
NewtonPrint(18, err_phys);
|
||||
NewtonPrint(41, real_dx_norm);
|
||||
@@ -299,7 +299,7 @@ int InverseElementTransformation::NewtonSolve(const Vector &pt,
|
||||
}
|
||||
if (print_level >= 3)
|
||||
{
|
||||
NewtonPrint(1, double(it));
|
||||
NewtonPrint(1, real_t(it));
|
||||
xip.Get(xd, dim); // xip -> x
|
||||
NewtonPrintPoint(", ref_pt", x, "\n");
|
||||
}
|
||||
@@ -310,7 +310,7 @@ int InverseElementTransformation::NewtonSolve(const Vector &pt,
|
||||
{
|
||||
if (print_level >= 1)
|
||||
{
|
||||
NewtonPrint(1, (double)it);
|
||||
NewtonPrint(1, (real_t)it);
|
||||
NewtonPrint(27, dx_norm);
|
||||
}
|
||||
ip = xip;
|
||||
@@ -322,7 +322,7 @@ int InverseElementTransformation::NewtonSolve(const Vector &pt,
|
||||
{
|
||||
if (print_level <= 1)
|
||||
{
|
||||
NewtonPrint(1, (double)max_iter);
|
||||
NewtonPrint(1, (real_t)max_iter);
|
||||
NewtonPrint(3, dx_norm);
|
||||
NewtonPrint(18, err_phys);
|
||||
if (hit_bdr) { NewtonPrint(41, real_dx_norm); }
|
||||
@@ -543,7 +543,7 @@ void IsoparametricTransformation::Transform (const DenseMatrix &matrix,
|
||||
void IntegrationPointTransformation::Transform (const IntegrationPoint &ip1,
|
||||
IntegrationPoint &ip2)
|
||||
{
|
||||
double vec[3];
|
||||
real_t vec[3];
|
||||
Vector v (vec, Transf.GetPointMat().Height());
|
||||
|
||||
Transf.Transform (ip1, v);
|
||||
@@ -640,7 +640,7 @@ void FaceElementTransformations::Transform(const DenseMatrix &matrix,
|
||||
IsoparametricTransformation::Transform(matrix, result);
|
||||
}
|
||||
|
||||
double FaceElementTransformations::CheckConsistency(int print_level,
|
||||
real_t FaceElementTransformations::CheckConsistency(int print_level,
|
||||
std::ostream &os)
|
||||
{
|
||||
// Check that the face vertices are mapped to the same physical location
|
||||
@@ -660,7 +660,7 @@ double FaceElementTransformations::CheckConsistency(int print_level,
|
||||
|
||||
const IntegrationRule &v_ir = *Geometries.GetVertices(GetGeometryType());
|
||||
|
||||
double max_dist = 0.0;
|
||||
real_t max_dist = 0.0;
|
||||
Vector dist(v_ir.GetNPoints());
|
||||
DenseMatrix coords_base, coords_el;
|
||||
IntegrationRule v_eir(v_ir.GetNPoints());
|
||||
|
||||
+11
-11
@@ -26,7 +26,7 @@ protected:
|
||||
const IntegrationPoint *IntPoint;
|
||||
DenseMatrix dFdx, adjJ, invJ;
|
||||
DenseMatrix d2Fdx2, adjJT;
|
||||
double Wght;
|
||||
real_t Wght;
|
||||
int EvalState;
|
||||
enum StateMasks
|
||||
{
|
||||
@@ -47,7 +47,7 @@ protected:
|
||||
store it in d2Fdx2. */
|
||||
virtual const DenseMatrix &EvalHessian() = 0;
|
||||
|
||||
double EvalWeight();
|
||||
real_t EvalWeight();
|
||||
const DenseMatrix &EvalAdjugateJ();
|
||||
const DenseMatrix &EvalTransAdjugateJ();
|
||||
const DenseMatrix &EvalInverseJ();
|
||||
@@ -128,7 +128,7 @@ public:
|
||||
/** @brief Return the weight of the Jacobian matrix of the transformation
|
||||
at the currently set IntegrationPoint.
|
||||
The Weight evaluates to \f$ \sqrt{\lvert J^T J \rvert} \f$. */
|
||||
double Weight() { return (EvalState & WEIGHT_MASK) ? Wght : EvalWeight(); }
|
||||
real_t Weight() { return (EvalState & WEIGHT_MASK) ? Wght : EvalWeight(); }
|
||||
|
||||
/** @brief Return the adjugate of the Jacobian matrix of the transformation
|
||||
at the currently set IntegrationPoint. */
|
||||
@@ -237,12 +237,12 @@ protected:
|
||||
int rel_qpts_order; // num_1D_qpts = max(trans_order+rel_qpts_order,0)+1
|
||||
int solver_type; // solution strategy to use
|
||||
int max_iter; // max. number of Newton iterations
|
||||
double ref_tol; // reference space tolerance
|
||||
double phys_rtol; // physical space tolerance (relative)
|
||||
double ip_tol; // tolerance for checking if a point is inside the ref. elem.
|
||||
real_t ref_tol; // reference space tolerance
|
||||
real_t phys_rtol; // physical space tolerance (relative)
|
||||
real_t ip_tol; // tolerance for checking if a point is inside the ref. elem.
|
||||
int print_level;
|
||||
|
||||
void NewtonPrint(int mode, double val);
|
||||
void NewtonPrint(int mode, real_t val);
|
||||
void NewtonPrintPoint(const char *prefix, const Vector &pt,
|
||||
const char *suffix);
|
||||
int NewtonSolve(const Vector &pt, IntegrationPoint &ip);
|
||||
@@ -317,15 +317,15 @@ public:
|
||||
void SetMaxIter(int max_it) { max_iter = max_it; }
|
||||
|
||||
/// Set the reference-space convergence tolerance.
|
||||
void SetReferenceTol(double ref_sp_tol) { ref_tol = ref_sp_tol; }
|
||||
void SetReferenceTol(real_t ref_sp_tol) { ref_tol = ref_sp_tol; }
|
||||
|
||||
/// Set the relative physical-space convergence tolerance.
|
||||
void SetPhysicalRelTol(double phys_rel_tol) { phys_rtol = phys_rel_tol; }
|
||||
void SetPhysicalRelTol(real_t phys_rel_tol) { phys_rtol = phys_rel_tol; }
|
||||
|
||||
/** @brief Set the tolerance used to determine if a point lies inside or
|
||||
outside of the reference element. */
|
||||
/** This tolerance is used only with the pure #Newton solver. */
|
||||
void SetElementTol(double el_tol) { ip_tol = el_tol; }
|
||||
void SetElementTol(real_t el_tol) { ip_tol = el_tol; }
|
||||
|
||||
/// Set the desired print level, useful for debugging.
|
||||
/** The valid options are: -1 - never print (default); 0 - print only errors;
|
||||
@@ -612,7 +612,7 @@ public:
|
||||
|
||||
@warning This check will generally fail on periodic boundary faces.
|
||||
*/
|
||||
double CheckConsistency(int print_level = 0,
|
||||
real_t CheckConsistency(int print_level = 0,
|
||||
std::ostream &out = mfem::out);
|
||||
};
|
||||
|
||||
|
||||
+10
-10
@@ -50,7 +50,7 @@ void L2ZienkiewiczZhuEstimator::ComputeEstimates()
|
||||
smooth_flux_space->Update(false);
|
||||
|
||||
// TODO: move these parameters in the class, and add Set* methods.
|
||||
const double solver_tol = 1e-12;
|
||||
const real_t solver_tol = 1e-12;
|
||||
const int solver_max_it = 200;
|
||||
total_error = L2ZZErrorEstimator(integ, solution, *smooth_flux_space,
|
||||
*flux_space, error_estimates,
|
||||
@@ -124,7 +124,7 @@ void KellyErrorEstimator::ResetCoefficientFunctions()
|
||||
const auto order = FT->GetFE()->GetOrder();
|
||||
|
||||
// Poor man's face diameter.
|
||||
double diameter = 0.0;
|
||||
real_t diameter = 0.0;
|
||||
|
||||
Vector p1(mesh->SpaceDimension());
|
||||
Vector p2(mesh->SpaceDimension());
|
||||
@@ -145,7 +145,7 @@ void KellyErrorEstimator::ResetCoefficientFunctions()
|
||||
auto fip2 = vtx_intrule->IntPoint(j);
|
||||
FT->Transform(fip2, p2);
|
||||
|
||||
diameter = std::max<double>(diameter, p2.DistanceTo(p1));
|
||||
diameter = std::max(diameter, p2.DistanceTo(p1));
|
||||
}
|
||||
}
|
||||
return diameter/(2.0*order);
|
||||
@@ -314,7 +314,7 @@ void KellyErrorEstimator::ComputeEstimates()
|
||||
jumps(i) *= jumps(i);
|
||||
}
|
||||
auto h_k_face = compute_face_coefficient(mesh, f, false);
|
||||
double jump_integral = h_k_face*jumps.Sum();
|
||||
real_t jump_integral = h_k_face*jumps.Sum();
|
||||
|
||||
// A local face is shared between two local elements, so we
|
||||
// can get away with integrating the jump only once and add
|
||||
@@ -442,7 +442,7 @@ void KellyErrorEstimator::ComputeEstimates()
|
||||
jumps(i) *= jumps(i);
|
||||
}
|
||||
auto h_k_face = compute_face_coefficient(mesh, sf, true);
|
||||
double jump_integral = h_k_face*jumps.Sum();
|
||||
real_t jump_integral = h_k_face*jumps.Sum();
|
||||
|
||||
error_estimates(FT->Elem1No) += jump_integral;
|
||||
// We skip "error_estimates(FT->Elem2No) += jump_integral"
|
||||
@@ -463,9 +463,9 @@ void KellyErrorEstimator::ComputeEstimates()
|
||||
auto pfes = dynamic_cast<ParFiniteElementSpace*>(xfes);
|
||||
MFEM_VERIFY(pfes, "xfes is not a ParFiniteElementSpace pointer");
|
||||
|
||||
double process_local_error = pow(error_estimates.Norml2(),2.0);
|
||||
MPI_Allreduce(&process_local_error, &total_error, 1, MPI_DOUBLE,
|
||||
MPI_SUM, pfes->GetComm());
|
||||
real_t process_local_error = pow(error_estimates.Norml2(),2.0);
|
||||
MPI_Allreduce(&process_local_error, &total_error, 1,
|
||||
MPITypeMap<real_t>::mpi_type, MPI_SUM, pfes->GetComm());
|
||||
total_error = sqrt(total_error);
|
||||
#endif // MFEM_USE_MPI
|
||||
}
|
||||
@@ -490,8 +490,8 @@ void LpErrorEstimator::ComputeEstimates()
|
||||
if (pfes)
|
||||
{
|
||||
auto process_local_error = total_error;
|
||||
MPI_Allreduce(&process_local_error, &total_error, 1, MPI_DOUBLE,
|
||||
MPI_SUM, pfes->GetComm());
|
||||
MPI_Allreduce(&process_local_error, &total_error, 1,
|
||||
MPITypeMap<real_t>::mpi_type, MPI_SUM, pfes->GetComm());
|
||||
}
|
||||
#endif // MFEM_USE_MPI
|
||||
total_error = pow(total_error, 1.0/local_norm_p);
|
||||
|
||||
+14
-14
@@ -44,7 +44,7 @@ public:
|
||||
/// Return the total error from the last error estimate.
|
||||
/** @note This method is optional for derived classes to override and the
|
||||
base class implementation simply returns 0. */
|
||||
virtual double GetTotalError() const { return 0.0; }
|
||||
virtual real_t GetTotalError() const { return 0.0; }
|
||||
|
||||
/// Get a Vector with all element errors.
|
||||
virtual const Vector &GetLocalErrors() = 0;
|
||||
@@ -90,7 +90,7 @@ class ZienkiewiczZhuEstimator : public AnisotropicErrorEstimator
|
||||
protected:
|
||||
long current_sequence;
|
||||
Vector error_estimates;
|
||||
double total_error;
|
||||
real_t total_error;
|
||||
bool anisotropic;
|
||||
Array<int> aniso_flags;
|
||||
int flux_averaging; // see SetFluxAveraging()
|
||||
@@ -172,7 +172,7 @@ public:
|
||||
void SetFluxAveraging(int fa) { flux_averaging = fa; }
|
||||
|
||||
/// Return the total error from the last error estimate.
|
||||
virtual double GetTotalError() const override { return total_error; }
|
||||
virtual real_t GetTotalError() const override { return total_error; }
|
||||
|
||||
/// Get a Vector with all element errors.
|
||||
virtual const Vector &GetLocalErrors() override
|
||||
@@ -243,9 +243,9 @@ class LSZienkiewiczZhuEstimator : public ErrorEstimator
|
||||
protected:
|
||||
long current_sequence;
|
||||
Vector error_estimates;
|
||||
double total_error;
|
||||
real_t total_error;
|
||||
bool subdomain_reconstruction = true;
|
||||
double tichonov_coeff;
|
||||
real_t tichonov_coeff;
|
||||
|
||||
BilinearFormIntegrator &integ;
|
||||
GridFunction &solution;
|
||||
@@ -291,14 +291,14 @@ public:
|
||||
* using tensor product elements, which typically require fewer
|
||||
* integration points and, therefore, may lead to an
|
||||
* ill-conditioned linear system. */
|
||||
void SetTichonovRegularization(double tcoeff = 1.0e-8)
|
||||
void SetTichonovRegularization(real_t tcoeff = 1.0e-8)
|
||||
{
|
||||
MFEM_VERIFY(tcoeff >= 0.0, "Tichonov coefficient cannot be negative");
|
||||
tichonov_coeff = tcoeff;
|
||||
}
|
||||
|
||||
/// Return the total error from the last error estimate.
|
||||
virtual double GetTotalError() const override { return total_error; }
|
||||
virtual real_t GetTotalError() const override { return total_error; }
|
||||
|
||||
/// Get a Vector with all element errors.
|
||||
virtual const Vector &GetLocalErrors() override
|
||||
@@ -331,7 +331,7 @@ protected:
|
||||
long current_sequence;
|
||||
int local_norm_p; ///< Local L_p norm to use, default is 1.
|
||||
Vector error_estimates;
|
||||
double total_error;
|
||||
real_t total_error;
|
||||
|
||||
BilinearFormIntegrator &integ;
|
||||
ParGridFunction &solution;
|
||||
@@ -411,7 +411,7 @@ public:
|
||||
void SetLocalErrorNormP(int p) { local_norm_p = p; }
|
||||
|
||||
/// Return the total error from the last error estimate.
|
||||
virtual double GetTotalError() const override { return total_error; }
|
||||
virtual real_t GetTotalError() const override { return total_error; }
|
||||
|
||||
/// Get a Vector with all element errors.
|
||||
virtual const Vector &GetLocalErrors() override
|
||||
@@ -452,7 +452,7 @@ protected:
|
||||
int local_norm_p;
|
||||
Vector error_estimates;
|
||||
|
||||
double total_error = 0.0;
|
||||
real_t total_error = 0.0;
|
||||
|
||||
Coefficient * coef;
|
||||
VectorCoefficient * vcoef;
|
||||
@@ -557,18 +557,18 @@ class KellyErrorEstimator final : public ErrorEstimator
|
||||
public:
|
||||
/// Function type to compute the local coefficient hₑ of an element.
|
||||
using ElementCoefficientFunction =
|
||||
std::function<double(Mesh*, const int)>;
|
||||
std::function<real_t(Mesh*, const int)>;
|
||||
/** @brief Function type to compute the local coefficient hₖ of a face. The
|
||||
third argument is true for shared faces and false for local faces. */
|
||||
using FaceCoefficientFunction =
|
||||
std::function<double(Mesh*, const int, const bool)>;
|
||||
std::function<real_t(Mesh*, const int, const bool)>;
|
||||
|
||||
private:
|
||||
int current_sequence = -1;
|
||||
|
||||
Vector error_estimates;
|
||||
|
||||
double total_error = 0.0;
|
||||
real_t total_error = 0.0;
|
||||
|
||||
Array<int> attributes;
|
||||
|
||||
@@ -661,7 +661,7 @@ public:
|
||||
/// Reset the error estimator.
|
||||
void Reset() override { current_sequence = -1; };
|
||||
|
||||
virtual double GetTotalError() const override { return total_error; }
|
||||
virtual real_t GetTotalError() const override { return total_error; }
|
||||
|
||||
/** @brief Change the method to compute hₑ on a per-element basis.
|
||||
@param compute_element_coefficient_
|
||||
|
||||
+86
-86
@@ -523,7 +523,7 @@ void ScalarFiniteElement::NodalLocalInterpolation(
|
||||
ElementTransformation &Trans, DenseMatrix &I,
|
||||
const ScalarFiniteElement &fine_fe) const
|
||||
{
|
||||
double v[Geometry::MaxDim];
|
||||
real_t v[Geometry::MaxDim];
|
||||
Vector vv(v, dim);
|
||||
IntegrationPoint f_ip;
|
||||
|
||||
@@ -564,7 +564,7 @@ void ScalarFiniteElement::ScalarLocalInterpolation(
|
||||
{
|
||||
// General "interpolation", defined by L2 projection
|
||||
|
||||
double v[Geometry::MaxDim];
|
||||
real_t v[Geometry::MaxDim];
|
||||
Vector vv(v, dim);
|
||||
IntegrationPoint f_ip;
|
||||
|
||||
@@ -604,7 +604,7 @@ void ScalarFiniteElement::ScalarLocalL2Restriction(
|
||||
const ScalarFiniteElement &coarse_fe) const
|
||||
{
|
||||
// General "restriction", defined by L2 projection
|
||||
double v[Geometry::MaxDim];
|
||||
real_t v[Geometry::MaxDim];
|
||||
Vector vv(v, dim);
|
||||
|
||||
const int cs = coarse_fe.GetDof(), fs = this->GetDof();
|
||||
@@ -732,7 +732,7 @@ void NodalFiniteElement::ProjectCurl_2D(
|
||||
{
|
||||
fe.CalcCurlShape(Nodes.IntPoint(i), curl_shape);
|
||||
|
||||
double w = 1.0;
|
||||
real_t w = 1.0;
|
||||
if (GetMapType() == FiniteElement::VALUE)
|
||||
{
|
||||
Trans.SetIntPoint(&Nodes.IntPoint(i));
|
||||
@@ -753,7 +753,7 @@ void InvertLinearTrans(ElementTransformation &trans,
|
||||
p0.Set3(0, 0, 0);
|
||||
trans.Transform(p0, x);
|
||||
|
||||
double store[3];
|
||||
real_t store[3];
|
||||
Vector v(store, x.Size());
|
||||
pt.Get(store, x.Size());
|
||||
v -= x;
|
||||
@@ -946,7 +946,7 @@ void NodalFiniteElement::ProjectDiv(
|
||||
const FiniteElement &fe, ElementTransformation &Trans,
|
||||
DenseMatrix &div) const
|
||||
{
|
||||
double detJ;
|
||||
real_t detJ;
|
||||
Vector div_shape(fe.GetDof());
|
||||
|
||||
div.SetSize(dof, fe.GetDof());
|
||||
@@ -1064,10 +1064,10 @@ void VectorFiniteElement::CalcVShape_ND(
|
||||
}
|
||||
|
||||
void VectorFiniteElement::Project_RT(
|
||||
const double *nk, const Array<int> &d2n,
|
||||
const real_t *nk, const Array<int> &d2n,
|
||||
VectorCoefficient &vc, ElementTransformation &Trans, Vector &dofs) const
|
||||
{
|
||||
double vk[Geometry::MaxDim];
|
||||
real_t vk[Geometry::MaxDim];
|
||||
const int sdim = Trans.GetSpaceDim();
|
||||
MFEM_ASSERT(vc.GetVDim() == sdim, "");
|
||||
Vector xk(vk, sdim);
|
||||
@@ -1084,7 +1084,7 @@ void VectorFiniteElement::Project_RT(
|
||||
}
|
||||
|
||||
void VectorFiniteElement::Project_RT(
|
||||
const double *nk, const Array<int> &d2n,
|
||||
const real_t *nk, const Array<int> &d2n,
|
||||
Vector &vc, ElementTransformation &Trans, Vector &dofs) const
|
||||
{
|
||||
const int sdim = Trans.GetSpaceDim();
|
||||
@@ -1101,7 +1101,7 @@ void VectorFiniteElement::Project_RT(
|
||||
}
|
||||
|
||||
void VectorFiniteElement::ProjectMatrixCoefficient_RT(
|
||||
const double *nk, const Array<int> &d2n,
|
||||
const real_t *nk, const Array<int> &d2n,
|
||||
MatrixCoefficient &mc, ElementTransformation &T, Vector &dofs) const
|
||||
{
|
||||
// project the rows of the matrix coefficient in an RT space
|
||||
@@ -1129,12 +1129,12 @@ void VectorFiniteElement::ProjectMatrixCoefficient_RT(
|
||||
}
|
||||
|
||||
void VectorFiniteElement::Project_RT(
|
||||
const double *nk, const Array<int> &d2n, const FiniteElement &fe,
|
||||
const real_t *nk, const Array<int> &d2n, const FiniteElement &fe,
|
||||
ElementTransformation &Trans, DenseMatrix &I) const
|
||||
{
|
||||
if (fe.GetRangeType() == SCALAR)
|
||||
{
|
||||
double vk[Geometry::MaxDim];
|
||||
real_t vk[Geometry::MaxDim];
|
||||
Vector shape(fe.GetDof());
|
||||
int sdim = Trans.GetSpaceDim();
|
||||
|
||||
@@ -1150,7 +1150,7 @@ void VectorFiniteElement::Project_RT(
|
||||
Trans.AdjugateJacobian().MultTranspose(nk + d2n[k]*dim, vk);
|
||||
if (fe.GetMapType() == INTEGRAL)
|
||||
{
|
||||
double w = 1.0/Trans.Weight();
|
||||
real_t w = 1.0/Trans.Weight();
|
||||
for (int d = 0; d < dim; d++)
|
||||
{
|
||||
vk[d] *= w;
|
||||
@@ -1159,7 +1159,7 @@ void VectorFiniteElement::Project_RT(
|
||||
|
||||
for (int j = 0; j < shape.Size(); j++)
|
||||
{
|
||||
double s = shape(j);
|
||||
real_t s = shape(j);
|
||||
if (fabs(s) < 1e-12)
|
||||
{
|
||||
s = 0.0;
|
||||
@@ -1176,7 +1176,7 @@ void VectorFiniteElement::Project_RT(
|
||||
else
|
||||
{
|
||||
int sdim = Trans.GetSpaceDim();
|
||||
double vk[Geometry::MaxDim];
|
||||
real_t vk[Geometry::MaxDim];
|
||||
DenseMatrix vshape(fe.GetDof(), sdim);
|
||||
Vector vshapenk(fe.GetDof());
|
||||
const bool square_J = (dim == sdim);
|
||||
@@ -1204,7 +1204,7 @@ void VectorFiniteElement::Project_RT(
|
||||
}
|
||||
|
||||
void VectorFiniteElement::ProjectGrad_RT(
|
||||
const double *nk, const Array<int> &d2n, const FiniteElement &fe,
|
||||
const real_t *nk, const Array<int> &d2n, const FiniteElement &fe,
|
||||
ElementTransformation &Trans, DenseMatrix &grad) const
|
||||
{
|
||||
if (dim != 2)
|
||||
@@ -1214,7 +1214,7 @@ void VectorFiniteElement::ProjectGrad_RT(
|
||||
|
||||
DenseMatrix dshape(fe.GetDof(), fe.GetDim());
|
||||
Vector grad_k(fe.GetDof());
|
||||
double tk[2];
|
||||
real_t tk[2];
|
||||
|
||||
grad.SetSize(dof, fe.GetDof());
|
||||
for (int k = 0; k < dof; k++)
|
||||
@@ -1231,7 +1231,7 @@ void VectorFiniteElement::ProjectGrad_RT(
|
||||
}
|
||||
|
||||
void VectorFiniteElement::ProjectCurl_ND(
|
||||
const double *tk, const Array<int> &d2t, const FiniteElement &fe,
|
||||
const real_t *tk, const Array<int> &d2t, const FiniteElement &fe,
|
||||
ElementTransformation &Trans, DenseMatrix &curl) const
|
||||
{
|
||||
#ifdef MFEM_THREAD_SAFE
|
||||
@@ -1269,7 +1269,7 @@ void VectorFiniteElement::ProjectCurl_ND(
|
||||
}
|
||||
|
||||
void VectorFiniteElement::ProjectCurl_RT(
|
||||
const double *nk, const Array<int> &d2n, const FiniteElement &fe,
|
||||
const real_t *nk, const Array<int> &d2n, const FiniteElement &fe,
|
||||
ElementTransformation &Trans, DenseMatrix &curl) const
|
||||
{
|
||||
DenseMatrix curl_shape(fe.GetDof(), dim);
|
||||
@@ -1288,10 +1288,10 @@ void VectorFiniteElement::ProjectCurl_RT(
|
||||
}
|
||||
|
||||
void VectorFiniteElement::Project_ND(
|
||||
const double *tk, const Array<int> &d2t,
|
||||
const real_t *tk, const Array<int> &d2t,
|
||||
VectorCoefficient &vc, ElementTransformation &Trans, Vector &dofs) const
|
||||
{
|
||||
double vk[Geometry::MaxDim];
|
||||
real_t vk[Geometry::MaxDim];
|
||||
Vector xk(vk, vc.GetVDim());
|
||||
|
||||
for (int k = 0; k < dof; k++)
|
||||
@@ -1305,7 +1305,7 @@ void VectorFiniteElement::Project_ND(
|
||||
}
|
||||
|
||||
void VectorFiniteElement::Project_ND(
|
||||
const double *tk, const Array<int> &d2t,
|
||||
const real_t *tk, const Array<int> &d2t,
|
||||
Vector &vc, ElementTransformation &Trans, Vector &dofs) const
|
||||
{
|
||||
for (int k = 0; k < dof; k++)
|
||||
@@ -1317,7 +1317,7 @@ void VectorFiniteElement::Project_ND(
|
||||
}
|
||||
|
||||
void VectorFiniteElement::ProjectMatrixCoefficient_ND(
|
||||
const double *tk, const Array<int> &d2t,
|
||||
const real_t *tk, const Array<int> &d2t,
|
||||
MatrixCoefficient &mc, ElementTransformation &T, Vector &dofs) const
|
||||
{
|
||||
// project the rows of the matrix coefficient in an ND space
|
||||
@@ -1343,13 +1343,13 @@ void VectorFiniteElement::ProjectMatrixCoefficient_ND(
|
||||
}
|
||||
|
||||
void VectorFiniteElement::Project_ND(
|
||||
const double *tk, const Array<int> &d2t, const FiniteElement &fe,
|
||||
const real_t *tk, const Array<int> &d2t, const FiniteElement &fe,
|
||||
ElementTransformation &Trans, DenseMatrix &I) const
|
||||
{
|
||||
if (fe.GetRangeType() == SCALAR)
|
||||
{
|
||||
int sdim = Trans.GetSpaceDim();
|
||||
double vk[Geometry::MaxDim];
|
||||
real_t vk[Geometry::MaxDim];
|
||||
Vector shape(fe.GetDof());
|
||||
|
||||
I.SetSize(dof, sdim*fe.GetDof());
|
||||
@@ -1364,7 +1364,7 @@ void VectorFiniteElement::Project_ND(
|
||||
Trans.Jacobian().Mult(tk + d2t[k]*dim, vk);
|
||||
if (fe.GetMapType() == INTEGRAL)
|
||||
{
|
||||
double w = 1.0/Trans.Weight();
|
||||
real_t w = 1.0/Trans.Weight();
|
||||
for (int d = 0; d < sdim; d++)
|
||||
{
|
||||
vk[d] *= w;
|
||||
@@ -1373,7 +1373,7 @@ void VectorFiniteElement::Project_ND(
|
||||
|
||||
for (int j = 0; j < shape.Size(); j++)
|
||||
{
|
||||
double s = shape(j);
|
||||
real_t s = shape(j);
|
||||
if (fabs(s) < 1e-12)
|
||||
{
|
||||
s = 0.0;
|
||||
@@ -1390,7 +1390,7 @@ void VectorFiniteElement::Project_ND(
|
||||
else
|
||||
{
|
||||
int sdim = Trans.GetSpaceDim();
|
||||
double vk[Geometry::MaxDim];
|
||||
real_t vk[Geometry::MaxDim];
|
||||
DenseMatrix vshape(fe.GetDof(), sdim);
|
||||
Vector vshapetk(fe.GetDof());
|
||||
|
||||
@@ -1416,7 +1416,7 @@ void VectorFiniteElement::Project_ND(
|
||||
}
|
||||
|
||||
void VectorFiniteElement::ProjectGrad_ND(
|
||||
const double *tk, const Array<int> &d2t, const FiniteElement &fe,
|
||||
const real_t *tk, const Array<int> &d2t, const FiniteElement &fe,
|
||||
ElementTransformation &Trans, DenseMatrix &grad) const
|
||||
{
|
||||
MFEM_ASSERT(fe.GetMapType() == VALUE, "");
|
||||
@@ -1456,7 +1456,7 @@ void VectorFiniteElement::LocalL2Projection_RT(
|
||||
for (int i = 0; i < ir.GetNPoints(); i++)
|
||||
{
|
||||
const IntegrationPoint &ip = ir.IntPoint(i);
|
||||
double w = ip.weight;
|
||||
real_t w = ip.weight;
|
||||
this->CalcVShape(ip, fine_shape);
|
||||
Trans.Transform(ip, v);
|
||||
tr_ip.Set(v.GetData(), dim);
|
||||
@@ -1467,7 +1467,7 @@ void VectorFiniteElement::LocalL2Projection_RT(
|
||||
{
|
||||
for (int j=0; j<cs; ++j)
|
||||
{
|
||||
double Mkj = 0.0;
|
||||
real_t Mkj = 0.0;
|
||||
for (int d1=0; d1<dim; ++d1)
|
||||
{
|
||||
for (int d2=0; d2<dim; ++d2)
|
||||
@@ -1484,14 +1484,14 @@ void VectorFiniteElement::LocalL2Projection_RT(
|
||||
}
|
||||
|
||||
void VectorFiniteElement::LocalInterpolation_RT(
|
||||
const VectorFiniteElement &cfe, const double *nk, const Array<int> &d2n,
|
||||
const VectorFiniteElement &cfe, const real_t *nk, const Array<int> &d2n,
|
||||
ElementTransformation &Trans, DenseMatrix &I) const
|
||||
{
|
||||
MFEM_ASSERT(map_type == cfe.GetMapType(), "");
|
||||
|
||||
if (!is_nodal) { return LocalL2Projection_RT(cfe, Trans, I); }
|
||||
|
||||
double vk[Geometry::MaxDim];
|
||||
real_t vk[Geometry::MaxDim];
|
||||
Vector xk(vk, dim);
|
||||
IntegrationPoint ip;
|
||||
#ifdef MFEM_THREAD_SAFE
|
||||
@@ -1514,7 +1514,7 @@ void VectorFiniteElement::LocalInterpolation_RT(
|
||||
// I_k = vshape_k.adj(J)^t.n_k, k=1,...,dof
|
||||
for (int j = 0; j < vshape.Height(); j++)
|
||||
{
|
||||
double Ikj = 0.;
|
||||
real_t Ikj = 0.;
|
||||
for (int i = 0; i < dim; i++)
|
||||
{
|
||||
Ikj += vshape(j, i) * vk[i];
|
||||
@@ -1554,7 +1554,7 @@ void VectorFiniteElement::LocalL2Projection_ND(
|
||||
{
|
||||
for (int j=0; j<cs; ++j)
|
||||
{
|
||||
double Mkj = 0.0;
|
||||
real_t Mkj = 0.0;
|
||||
for (int d1=0; d1<dim; ++d1)
|
||||
{
|
||||
for (int d2=0; d2<dim; ++d2)
|
||||
@@ -1571,12 +1571,12 @@ void VectorFiniteElement::LocalL2Projection_ND(
|
||||
}
|
||||
|
||||
void VectorFiniteElement::LocalInterpolation_ND(
|
||||
const VectorFiniteElement &cfe, const double *tk, const Array<int> &d2t,
|
||||
const VectorFiniteElement &cfe, const real_t *tk, const Array<int> &d2t,
|
||||
ElementTransformation &Trans, DenseMatrix &I) const
|
||||
{
|
||||
if (!is_nodal) { return LocalL2Projection_ND(cfe, Trans, I); }
|
||||
|
||||
double vk[Geometry::MaxDim];
|
||||
real_t vk[Geometry::MaxDim];
|
||||
Vector xk(vk, dim);
|
||||
IntegrationPoint ip;
|
||||
#ifdef MFEM_THREAD_SAFE
|
||||
@@ -1599,7 +1599,7 @@ void VectorFiniteElement::LocalInterpolation_ND(
|
||||
// I_k = vshape_k.J.t_k, k=1,...,Dof
|
||||
for (int j = 0; j < vshape.Height(); j++)
|
||||
{
|
||||
double Ikj = 0.;
|
||||
real_t Ikj = 0.;
|
||||
for (int i = 0; i < dim; i++)
|
||||
{
|
||||
Ikj += vshape(j, i) * vk[i];
|
||||
@@ -1610,10 +1610,10 @@ void VectorFiniteElement::LocalInterpolation_ND(
|
||||
}
|
||||
|
||||
void VectorFiniteElement::LocalRestriction_RT(
|
||||
const double *nk, const Array<int> &d2n, ElementTransformation &Trans,
|
||||
const real_t *nk, const Array<int> &d2n, ElementTransformation &Trans,
|
||||
DenseMatrix &R) const
|
||||
{
|
||||
double pt_data[Geometry::MaxDim];
|
||||
real_t pt_data[Geometry::MaxDim];
|
||||
IntegrationPoint ip;
|
||||
Vector pt(pt_data, dim);
|
||||
|
||||
@@ -1623,7 +1623,7 @@ void VectorFiniteElement::LocalRestriction_RT(
|
||||
|
||||
Trans.SetIntPoint(&Geometries.GetCenter(geom_type));
|
||||
const DenseMatrix &J = Trans.Jacobian();
|
||||
const double weight = Trans.Weight();
|
||||
const real_t weight = Trans.Weight();
|
||||
for (int j = 0; j < dof; j++)
|
||||
{
|
||||
InvertLinearTrans(Trans, Nodes.IntPoint(j), pt);
|
||||
@@ -1635,7 +1635,7 @@ void VectorFiniteElement::LocalRestriction_RT(
|
||||
pt /= weight;
|
||||
for (int k = 0; k < dof; k++)
|
||||
{
|
||||
double R_jk = 0.0;
|
||||
real_t R_jk = 0.0;
|
||||
for (int d = 0; d < dim; d++)
|
||||
{
|
||||
R_jk += vshape(k,d)*pt_data[d];
|
||||
@@ -1653,10 +1653,10 @@ void VectorFiniteElement::LocalRestriction_RT(
|
||||
}
|
||||
|
||||
void VectorFiniteElement::LocalRestriction_ND(
|
||||
const double *tk, const Array<int> &d2t, ElementTransformation &Trans,
|
||||
const real_t *tk, const Array<int> &d2t, ElementTransformation &Trans,
|
||||
DenseMatrix &R) const
|
||||
{
|
||||
double pt_data[Geometry::MaxDim];
|
||||
real_t pt_data[Geometry::MaxDim];
|
||||
IntegrationPoint ip;
|
||||
Vector pt(pt_data, dim);
|
||||
|
||||
@@ -1676,7 +1676,7 @@ void VectorFiniteElement::LocalRestriction_ND(
|
||||
Jinv.Mult(tk+dim*d2t[j], pt_data);
|
||||
for (int k = 0; k < dof; k++)
|
||||
{
|
||||
double R_jk = 0.0;
|
||||
real_t R_jk = 0.0;
|
||||
for (int d = 0; d < dim; d++)
|
||||
{
|
||||
R_jk += vshape(k,d)*pt_data[d];
|
||||
@@ -1694,7 +1694,7 @@ void VectorFiniteElement::LocalRestriction_ND(
|
||||
}
|
||||
|
||||
|
||||
Poly_1D::Basis::Basis(const int p, const double *nodes, EvalType etype)
|
||||
Poly_1D::Basis::Basis(const int p, const real_t *nodes, EvalType etype)
|
||||
: etype(etype), auxiliary_basis(NULL), scale_integrated(false)
|
||||
{
|
||||
switch (etype)
|
||||
@@ -1722,7 +1722,7 @@ Poly_1D::Basis::Basis(const int p, const double *nodes, EvalType etype)
|
||||
{
|
||||
for (int j = 0; j < i; j++)
|
||||
{
|
||||
double xij = x(i) - x(j);
|
||||
real_t xij = x(i) - x(j);
|
||||
w(i) *= xij;
|
||||
w(j) *= -xij;
|
||||
}
|
||||
@@ -1758,7 +1758,7 @@ Poly_1D::Basis::Basis(const int p, const double *nodes, EvalType etype)
|
||||
}
|
||||
}
|
||||
|
||||
void Poly_1D::Basis::Eval(const double y, Vector &u) const
|
||||
void Poly_1D::Basis::Eval(const real_t y, Vector &u) const
|
||||
{
|
||||
switch (etype)
|
||||
{
|
||||
@@ -1771,7 +1771,7 @@ void Poly_1D::Basis::Eval(const double y, Vector &u) const
|
||||
case Barycentric:
|
||||
{
|
||||
int i, k, p = x.Size() - 1;
|
||||
double l, lk;
|
||||
real_t l, lk;
|
||||
|
||||
if (p == 0)
|
||||
{
|
||||
@@ -1819,7 +1819,7 @@ void Poly_1D::Basis::Eval(const double y, Vector &u) const
|
||||
}
|
||||
}
|
||||
|
||||
void Poly_1D::Basis::Eval(const double y, Vector &u, Vector &d) const
|
||||
void Poly_1D::Basis::Eval(const real_t y, Vector &u, Vector &d) const
|
||||
{
|
||||
switch (etype)
|
||||
{
|
||||
@@ -1833,7 +1833,7 @@ void Poly_1D::Basis::Eval(const double y, Vector &u, Vector &d) const
|
||||
case Barycentric:
|
||||
{
|
||||
int i, k, p = x.Size() - 1;
|
||||
double l, lp, lk, sk, si;
|
||||
real_t l, lp, lk, sk, si;
|
||||
|
||||
if (p == 0)
|
||||
{
|
||||
@@ -1899,7 +1899,7 @@ void Poly_1D::Basis::Eval(const double y, Vector &u, Vector &d) const
|
||||
}
|
||||
}
|
||||
|
||||
void Poly_1D::Basis::Eval(const double y, Vector &u, Vector &d,
|
||||
void Poly_1D::Basis::Eval(const real_t y, Vector &u, Vector &d,
|
||||
Vector &d2) const
|
||||
{
|
||||
MFEM_VERIFY(etype == Barycentric,
|
||||
@@ -1918,7 +1918,7 @@ void Poly_1D::Basis::Eval(const double y, Vector &u, Vector &d,
|
||||
case Barycentric:
|
||||
{
|
||||
int i, k, p = x.Size() - 1;
|
||||
double l, lp, lp2, lk, sk, si, sk2;
|
||||
real_t l, lp, lp2, lk, sk, si, sk2;
|
||||
|
||||
if (p == 0)
|
||||
{
|
||||
@@ -2042,19 +2042,19 @@ const int *Poly_1D::Binom(const int p)
|
||||
return binom[p];
|
||||
}
|
||||
|
||||
void Poly_1D::ChebyshevPoints(const int p, double *x)
|
||||
void Poly_1D::ChebyshevPoints(const int p, real_t *x)
|
||||
{
|
||||
for (int i = 0; i <= p; i++)
|
||||
{
|
||||
// x[i] = 0.5*(1. + cos(M_PI*(p - i + 0.5)/(p + 1)));
|
||||
double s = sin(M_PI_2*(i + 0.5)/(p + 1));
|
||||
real_t s = sin(M_PI_2*(i + 0.5)/(p + 1));
|
||||
x[i] = s*s;
|
||||
}
|
||||
}
|
||||
|
||||
void Poly_1D::CalcMono(const int p, const double x, double *u)
|
||||
void Poly_1D::CalcMono(const int p, const real_t x, real_t *u)
|
||||
{
|
||||
double xn;
|
||||
real_t xn;
|
||||
u[0] = xn = 1.;
|
||||
for (int n = 1; n <= p; n++)
|
||||
{
|
||||
@@ -2062,9 +2062,9 @@ void Poly_1D::CalcMono(const int p, const double x, double *u)
|
||||
}
|
||||
}
|
||||
|
||||
void Poly_1D::CalcMono(const int p, const double x, double *u, double *d)
|
||||
void Poly_1D::CalcMono(const int p, const real_t x, real_t *u, real_t *d)
|
||||
{
|
||||
double xn;
|
||||
real_t xn;
|
||||
u[0] = xn = 1.;
|
||||
d[0] = 0.;
|
||||
for (int n = 1; n <= p; n++)
|
||||
@@ -2074,8 +2074,8 @@ void Poly_1D::CalcMono(const int p, const double x, double *u, double *d)
|
||||
}
|
||||
}
|
||||
|
||||
void Poly_1D::CalcBinomTerms(const int p, const double x, const double y,
|
||||
double *u)
|
||||
void Poly_1D::CalcBinomTerms(const int p, const real_t x, const real_t y,
|
||||
real_t *u)
|
||||
{
|
||||
if (p == 0)
|
||||
{
|
||||
@@ -2085,7 +2085,7 @@ void Poly_1D::CalcBinomTerms(const int p, const double x, const double y,
|
||||
{
|
||||
int i;
|
||||
const int *b = Binom(p);
|
||||
double z = x;
|
||||
real_t z = x;
|
||||
|
||||
for (i = 1; i < p; i++)
|
||||
{
|
||||
@@ -2103,8 +2103,8 @@ void Poly_1D::CalcBinomTerms(const int p, const double x, const double y,
|
||||
}
|
||||
}
|
||||
|
||||
void Poly_1D::CalcBinomTerms(const int p, const double x, const double y,
|
||||
double *u, double *d)
|
||||
void Poly_1D::CalcBinomTerms(const int p, const real_t x, const real_t y,
|
||||
real_t *u, real_t *d)
|
||||
{
|
||||
if (p == 0)
|
||||
{
|
||||
@@ -2115,8 +2115,8 @@ void Poly_1D::CalcBinomTerms(const int p, const double x, const double y,
|
||||
{
|
||||
int i;
|
||||
const int *b = Binom(p);
|
||||
const double xpy = x + y, ptx = p*x;
|
||||
double z = 1.;
|
||||
const real_t xpy = x + y, ptx = p*x;
|
||||
real_t z = 1.;
|
||||
|
||||
for (i = 1; i < p; i++)
|
||||
{
|
||||
@@ -2138,8 +2138,8 @@ void Poly_1D::CalcBinomTerms(const int p, const double x, const double y,
|
||||
}
|
||||
}
|
||||
|
||||
void Poly_1D::CalcDBinomTerms(const int p, const double x, const double y,
|
||||
double *d)
|
||||
void Poly_1D::CalcDBinomTerms(const int p, const real_t x, const real_t y,
|
||||
real_t *d)
|
||||
{
|
||||
if (p == 0)
|
||||
{
|
||||
@@ -2149,8 +2149,8 @@ void Poly_1D::CalcDBinomTerms(const int p, const double x, const double y,
|
||||
{
|
||||
int i;
|
||||
const int *b = Binom(p);
|
||||
const double xpy = x + y, ptx = p*x;
|
||||
double z = 1.;
|
||||
const real_t xpy = x + y, ptx = p*x;
|
||||
real_t z = 1.;
|
||||
|
||||
for (i = 1; i < p; i++)
|
||||
{
|
||||
@@ -2168,11 +2168,11 @@ void Poly_1D::CalcDBinomTerms(const int p, const double x, const double y,
|
||||
}
|
||||
}
|
||||
|
||||
void Poly_1D::CalcLegendre(const int p, const double x, double *u)
|
||||
void Poly_1D::CalcLegendre(const int p, const real_t x, real_t *u)
|
||||
{
|
||||
// use the recursive definition for [-1,1]:
|
||||
// (n+1)*P_{n+1}(z) = (2*n+1)*z*P_n(z)-n*P_{n-1}(z)
|
||||
double z;
|
||||
real_t z;
|
||||
u[0] = 1.;
|
||||
if (p == 0) { return; }
|
||||
u[1] = z = 2.*x - 1.;
|
||||
@@ -2182,13 +2182,13 @@ void Poly_1D::CalcLegendre(const int p, const double x, double *u)
|
||||
}
|
||||
}
|
||||
|
||||
void Poly_1D::CalcLegendre(const int p, const double x, double *u, double *d)
|
||||
void Poly_1D::CalcLegendre(const int p, const real_t x, real_t *u, real_t *d)
|
||||
{
|
||||
// use the recursive definition for [-1,1]:
|
||||
// (n+1)*P_{n+1}(z) = (2*n+1)*z*P_n(z)-n*P_{n-1}(z)
|
||||
// for the derivative use, z in [-1,1]:
|
||||
// P'_{n+1}(z) = (2*n+1)*P_n(z)+P'_{n-1}(z)
|
||||
double z;
|
||||
real_t z;
|
||||
u[0] = 1.;
|
||||
d[0] = 0.;
|
||||
if (p == 0) { return; }
|
||||
@@ -2201,12 +2201,12 @@ void Poly_1D::CalcLegendre(const int p, const double x, double *u, double *d)
|
||||
}
|
||||
}
|
||||
|
||||
void Poly_1D::CalcChebyshev(const int p, const double x, double *u)
|
||||
void Poly_1D::CalcChebyshev(const int p, const real_t x, real_t *u)
|
||||
{
|
||||
// recursive definition, z in [-1,1]
|
||||
// T_0(z) = 1, T_1(z) = z
|
||||
// T_{n+1}(z) = 2*z*T_n(z) - T_{n-1}(z)
|
||||
double z;
|
||||
real_t z;
|
||||
u[0] = 1.;
|
||||
if (p == 0) { return; }
|
||||
u[1] = z = 2.*x - 1.;
|
||||
@@ -2216,7 +2216,7 @@ void Poly_1D::CalcChebyshev(const int p, const double x, double *u)
|
||||
}
|
||||
}
|
||||
|
||||
void Poly_1D::CalcChebyshev(const int p, const double x, double *u, double *d)
|
||||
void Poly_1D::CalcChebyshev(const int p, const real_t x, real_t *u, real_t *d)
|
||||
{
|
||||
// recursive definition, z in [-1,1]
|
||||
// T_0(z) = 1, T_1(z) = z
|
||||
@@ -2226,7 +2226,7 @@ void Poly_1D::CalcChebyshev(const int p, const double x, double *u, double *d)
|
||||
// U_{n+1}(z) = 2*z*U_n(z) - U_{n-1}(z)
|
||||
// U_n(z) = z*U_{n-1}(z) + T_n(z) = z*T'_n(z)/n + T_n(z)
|
||||
// T'_{n+1}(z) = (n + 1)*(z*T'_n(z)/n + T_n(z))
|
||||
double z;
|
||||
real_t z;
|
||||
u[0] = 1.;
|
||||
d[0] = 0.;
|
||||
if (p == 0) { return; }
|
||||
@@ -2239,8 +2239,8 @@ void Poly_1D::CalcChebyshev(const int p, const double x, double *u, double *d)
|
||||
}
|
||||
}
|
||||
|
||||
void Poly_1D::CalcChebyshev(const int p, const double x, double *u, double *d,
|
||||
double *dd)
|
||||
void Poly_1D::CalcChebyshev(const int p, const real_t x, real_t *u, real_t *d,
|
||||
real_t *dd)
|
||||
{
|
||||
// recursive definition, z in [-1,1]
|
||||
// T_0(z) = 1, T_1(z) = z
|
||||
@@ -2251,7 +2251,7 @@ void Poly_1D::CalcChebyshev(const int p, const double x, double *u, double *d,
|
||||
// U_n(z) = z*U_{n-1}(z) + T_n(z) = z*T'_n(z)/n + T_n(z)
|
||||
// T'_{n+1}(z) = (n + 1)*(z*T'_n(z)/n + T_n(z))
|
||||
// T''_{n+1}(z) = (n + 1)*(2*(n + 1)*T'_n(z) + z*T''_n(z)) / n
|
||||
double z;
|
||||
real_t z;
|
||||
u[0] = 1.;
|
||||
d[0] = 0.;
|
||||
dd[0]= 0.;
|
||||
@@ -2267,9 +2267,9 @@ void Poly_1D::CalcChebyshev(const int p, const double x, double *u, double *d,
|
||||
}
|
||||
}
|
||||
|
||||
const double *Poly_1D::GetPoints(const int p, const int btype)
|
||||
const real_t *Poly_1D::GetPoints(const int p, const int btype)
|
||||
{
|
||||
Array<double*> *pts;
|
||||
Array<real_t*> *pts;
|
||||
BasisType::Check(btype);
|
||||
const int qtype = BasisType::GetQuadrature1D(btype);
|
||||
if (qtype == Quadrature1D::Invalid) { return NULL; }
|
||||
@@ -2285,7 +2285,7 @@ const double *Poly_1D::GetPoints(const int p, const int btype)
|
||||
}
|
||||
else
|
||||
{
|
||||
pts = new Array<double*>(h_mt);
|
||||
pts = new Array<real_t*>(h_mt);
|
||||
points_container[btype] = pts;
|
||||
}
|
||||
if (pts->Size() <= p)
|
||||
@@ -2294,7 +2294,7 @@ const double *Poly_1D::GetPoints(const int p, const int btype)
|
||||
}
|
||||
if ((*pts)[p] == NULL)
|
||||
{
|
||||
(*pts)[p] = new double[p + 1];
|
||||
(*pts)[p] = new real_t[p + 1];
|
||||
quad_func.GivePolyPoints(p + 1, (*pts)[p], qtype);
|
||||
}
|
||||
}
|
||||
@@ -2342,7 +2342,7 @@ Poly_1D::~Poly_1D()
|
||||
for (PointsMap::iterator it = points_container.begin();
|
||||
it != points_container.end() ; ++it)
|
||||
{
|
||||
Array<double*>& pts = *it->second;
|
||||
Array<real_t*>& pts = *it->second;
|
||||
for (int i = 0; i < pts.Size(); ++i)
|
||||
{
|
||||
delete [] pts[i];
|
||||
|
||||
+56
-56
@@ -186,13 +186,13 @@ public:
|
||||
|
||||
- dim = dimension of the finite element reference space when #mode is
|
||||
FULL, and dim = 1 when #mode is TENSOR. */
|
||||
Array<double> B;
|
||||
Array<real_t> B;
|
||||
|
||||
/// Transpose of #B.
|
||||
/** The storage layout is column-major with dimensions:
|
||||
- #ndof x #nqpt, for scalar elements, or
|
||||
- #ndof x #nqpt x dim, for vector elements. */
|
||||
Array<double> Bt;
|
||||
Array<real_t> Bt;
|
||||
|
||||
/** @brief Gradients/divergences/curls of basis functions evaluated at
|
||||
quadrature points. */
|
||||
@@ -207,14 +207,14 @@ public:
|
||||
FULL, and 1 when #mode is TENSOR,
|
||||
- cdim = 1/1/3 in 1D/2D/3D, respectively, when #mode is FULL, and cdim =
|
||||
1 when #mode is TENSOR. */
|
||||
Array<double> G;
|
||||
Array<real_t> G;
|
||||
|
||||
/// Transpose of #G.
|
||||
/** The storage layout is column-major with dimensions:
|
||||
- #ndof x #nqpt x dim, for scalar elements, or
|
||||
- #ndof x #nqpt, for H(div) vector elements, or
|
||||
- #ndof x #nqpt x cdim, for H(curl) vector elements. */
|
||||
Array<double> Gt;
|
||||
Array<real_t> Gt;
|
||||
};
|
||||
|
||||
/// Describes the function space on each element
|
||||
@@ -830,7 +830,7 @@ protected:
|
||||
@param Trans Transformation from reference to physical coordinates
|
||||
@param dofs Expansion coefficients for the approximation of vc
|
||||
*/
|
||||
void Project_RT(const double *nk, const Array<int> &d2n,
|
||||
void Project_RT(const real_t *nk, const Array<int> &d2n,
|
||||
VectorCoefficient &vc, ElementTransformation &Trans,
|
||||
Vector &dofs) const;
|
||||
|
||||
@@ -842,13 +842,13 @@ protected:
|
||||
@param Trans Transformation from reference to physical coordinates
|
||||
@param dofs Expansion coefficients for the approximation of vc
|
||||
*/
|
||||
void Project_RT(const double *nk, const Array<int> &d2n,
|
||||
void Project_RT(const real_t *nk, const Array<int> &d2n,
|
||||
Vector &vc, ElementTransformation &Trans,
|
||||
Vector &dofs) const;
|
||||
|
||||
/// Project the rows of the matrix coefficient in an RT space
|
||||
void ProjectMatrixCoefficient_RT(
|
||||
const double *nk, const Array<int> &d2n,
|
||||
const real_t *nk, const Array<int> &d2n,
|
||||
MatrixCoefficient &mc, ElementTransformation &T, Vector &dofs) const;
|
||||
|
||||
/** @brief Project vector-valued basis functions onto the RT basis functions
|
||||
@@ -864,22 +864,22 @@ protected:
|
||||
field using the scalar basis functions for each component of the
|
||||
vector field.
|
||||
*/
|
||||
void Project_RT(const double *nk, const Array<int> &d2n,
|
||||
void Project_RT(const real_t *nk, const Array<int> &d2n,
|
||||
const FiniteElement &fe, ElementTransformation &Trans,
|
||||
DenseMatrix &I) const;
|
||||
|
||||
// rotated gradient in 2D
|
||||
void ProjectGrad_RT(const double *nk, const Array<int> &d2n,
|
||||
void ProjectGrad_RT(const real_t *nk, const Array<int> &d2n,
|
||||
const FiniteElement &fe, ElementTransformation &Trans,
|
||||
DenseMatrix &grad) const;
|
||||
|
||||
// Compute the curl as a discrete operator from ND FE (fe) to ND FE (this).
|
||||
// The natural FE for the range is RT, so this is an approximation.
|
||||
void ProjectCurl_ND(const double *tk, const Array<int> &d2t,
|
||||
void ProjectCurl_ND(const real_t *tk, const Array<int> &d2t,
|
||||
const FiniteElement &fe, ElementTransformation &Trans,
|
||||
DenseMatrix &curl) const;
|
||||
|
||||
void ProjectCurl_RT(const double *nk, const Array<int> &d2n,
|
||||
void ProjectCurl_RT(const real_t *nk, const Array<int> &d2n,
|
||||
const FiniteElement &fe, ElementTransformation &Trans,
|
||||
DenseMatrix &curl) const;
|
||||
|
||||
@@ -890,7 +890,7 @@ protected:
|
||||
@param Trans Transformation from reference to physical coordinates
|
||||
@param dofs Expansion coefficients for the approximation of vc
|
||||
*/
|
||||
void Project_ND(const double *tk, const Array<int> &d2t,
|
||||
void Project_ND(const real_t *tk, const Array<int> &d2t,
|
||||
VectorCoefficient &vc, ElementTransformation &Trans,
|
||||
Vector &dofs) const;
|
||||
|
||||
@@ -902,13 +902,13 @@ protected:
|
||||
@param Trans Transformation from reference to physical coordinates
|
||||
@param dofs Expansion coefficients for the approximation of vc
|
||||
*/
|
||||
void Project_ND(const double *tk, const Array<int> &d2t,
|
||||
void Project_ND(const real_t *tk, const Array<int> &d2t,
|
||||
Vector &vc, ElementTransformation &Trans,
|
||||
Vector &dofs) const;
|
||||
|
||||
/// Project the rows of the matrix coefficient in an ND space
|
||||
void ProjectMatrixCoefficient_ND(
|
||||
const double *tk, const Array<int> &d2t,
|
||||
const real_t *tk, const Array<int> &d2t,
|
||||
MatrixCoefficient &mc, ElementTransformation &T, Vector &dofs) const;
|
||||
|
||||
/** @brief Project vector-valued basis functions onto the ND basis functions
|
||||
@@ -924,11 +924,11 @@ protected:
|
||||
field using the scalar basis functions for each component of the
|
||||
vector field.
|
||||
*/
|
||||
void Project_ND(const double *tk, const Array<int> &d2t,
|
||||
void Project_ND(const real_t *tk, const Array<int> &d2t,
|
||||
const FiniteElement &fe, ElementTransformation &Trans,
|
||||
DenseMatrix &I) const;
|
||||
|
||||
void ProjectGrad_ND(const double *tk, const Array<int> &d2t,
|
||||
void ProjectGrad_ND(const real_t *tk, const Array<int> &d2t,
|
||||
const FiniteElement &fe, ElementTransformation &Trans,
|
||||
DenseMatrix &grad) const;
|
||||
|
||||
@@ -937,7 +937,7 @@ protected:
|
||||
DenseMatrix &I) const;
|
||||
|
||||
void LocalInterpolation_RT(const VectorFiniteElement &cfe,
|
||||
const double *nk, const Array<int> &d2n,
|
||||
const real_t *nk, const Array<int> &d2n,
|
||||
ElementTransformation &Trans,
|
||||
DenseMatrix &I) const;
|
||||
|
||||
@@ -946,15 +946,15 @@ protected:
|
||||
DenseMatrix &I) const;
|
||||
|
||||
void LocalInterpolation_ND(const VectorFiniteElement &cfe,
|
||||
const double *tk, const Array<int> &d2t,
|
||||
const real_t *tk, const Array<int> &d2t,
|
||||
ElementTransformation &Trans,
|
||||
DenseMatrix &I) const;
|
||||
|
||||
void LocalRestriction_RT(const double *nk, const Array<int> &d2n,
|
||||
void LocalRestriction_RT(const real_t *nk, const Array<int> &d2n,
|
||||
ElementTransformation &Trans,
|
||||
DenseMatrix &R) const;
|
||||
|
||||
void LocalRestriction_ND(const double *tk, const Array<int> &d2t,
|
||||
void LocalRestriction_ND(const real_t *tk, const Array<int> &d2t,
|
||||
ElementTransformation &Trans,
|
||||
DenseMatrix &R) const;
|
||||
|
||||
@@ -1006,15 +1006,15 @@ public:
|
||||
|
||||
public:
|
||||
/// Create a nodal or positive (Bernstein) basis of degree @a p
|
||||
Basis(const int p, const double *nodes, EvalType etype = Barycentric);
|
||||
Basis(const int p, const real_t *nodes, EvalType etype = Barycentric);
|
||||
/// Evaluate the basis functions at point @a x in [0,1]
|
||||
void Eval(const double x, Vector &u) const;
|
||||
void Eval(const real_t x, Vector &u) const;
|
||||
/// @brief Evaluate the basis functions and their derivatives at point @a
|
||||
/// x in [0,1]
|
||||
void Eval(const double x, Vector &u, Vector &d) const;
|
||||
void Eval(const real_t x, Vector &u, Vector &d) const;
|
||||
/// @brief Evaluate the basis functions and their first two derivatives at
|
||||
/// point @a x in [0,1]
|
||||
void Eval(const double x, Vector &u, Vector &d, Vector &d2) const;
|
||||
void Eval(const real_t x, Vector &u, Vector &d, Vector &d2) const;
|
||||
/// @brief Evaluate the "integrated" basis type using pre-computed closed
|
||||
/// basis derivatives.
|
||||
///
|
||||
@@ -1037,7 +1037,7 @@ public:
|
||||
};
|
||||
|
||||
private:
|
||||
typedef std::map<int, Array<double*>*> PointsMap;
|
||||
typedef std::map<int, Array<real_t*>*> PointsMap;
|
||||
typedef std::map<int, Array<Basis*>*> BasisMap;
|
||||
|
||||
MemoryType h_mt;
|
||||
@@ -1046,13 +1046,13 @@ private:
|
||||
|
||||
static Array2D<int> binom;
|
||||
|
||||
static void CalcMono(const int p, const double x, double *u);
|
||||
static void CalcMono(const int p, const double x, double *u, double *d);
|
||||
static void CalcMono(const int p, const real_t x, real_t *u);
|
||||
static void CalcMono(const int p, const real_t x, real_t *u, real_t *d);
|
||||
|
||||
static void CalcChebyshev(const int p, const double x, double *u);
|
||||
static void CalcChebyshev(const int p, const double x, double *u, double *d);
|
||||
static void CalcChebyshev(const int p, const double x, double *u, double *d,
|
||||
double *dd);
|
||||
static void CalcChebyshev(const int p, const real_t x, real_t *u);
|
||||
static void CalcChebyshev(const int p, const real_t x, real_t *u, real_t *d);
|
||||
static void CalcChebyshev(const int p, const real_t x, real_t *u, real_t *d,
|
||||
real_t *dd);
|
||||
|
||||
QuadratureFunctions1D quad_func;
|
||||
|
||||
@@ -1072,15 +1072,15 @@ public:
|
||||
@return A pointer to an array containing the `p+1` coordinates of the
|
||||
points. Returns NULL if the BasisType has no associated set of
|
||||
points. */
|
||||
const double *GetPoints(const int p, const int btype);
|
||||
const real_t *GetPoints(const int p, const int btype);
|
||||
|
||||
/// Get coordinates of an open (GaussLegendre) set of points if degree @a p
|
||||
const double *OpenPoints(const int p,
|
||||
const real_t *OpenPoints(const int p,
|
||||
const int btype = BasisType::GaussLegendre)
|
||||
{ return GetPoints(p, btype); }
|
||||
|
||||
/// Get coordinates of a closed (GaussLegendre) set of points if degree @a p
|
||||
const double *ClosedPoints(const int p,
|
||||
const real_t *ClosedPoints(const int p,
|
||||
const int btype = BasisType::GaussLobatto)
|
||||
{ return GetPoints(p, btype); }
|
||||
|
||||
@@ -1096,7 +1096,7 @@ public:
|
||||
|
||||
/** @brief Evaluate the values of a hierarchical 1D basis at point x
|
||||
hierarchical = k-th basis function is degree k polynomial */
|
||||
static void CalcBasis(const int p, const double x, double *u)
|
||||
static void CalcBasis(const int p, const real_t x, real_t *u)
|
||||
// { CalcMono(p, x, u); }
|
||||
// Bernstein basis is not hierarchical --> does not work for triangles
|
||||
// and tetrahedra
|
||||
@@ -1106,11 +1106,11 @@ public:
|
||||
|
||||
/** @brief Evaluate the values of a hierarchical 1D basis at point x
|
||||
hierarchical = k-th basis function is degree k polynomial */
|
||||
static void CalcBasis(const int p, const double x, Vector &u)
|
||||
static void CalcBasis(const int p, const real_t x, Vector &u)
|
||||
{ CalcBasis(p, x, u.GetData()); }
|
||||
|
||||
/// Evaluate the values and derivatives of a hierarchical 1D basis at point @a x
|
||||
static void CalcBasis(const int p, const double x, double *u, double *d)
|
||||
static void CalcBasis(const int p, const real_t x, real_t *u, real_t *d)
|
||||
// { CalcMono(p, x, u, d); }
|
||||
// { CalcBernstein(p, x, u, d); }
|
||||
// { CalcLegendre(p, x, u, d); }
|
||||
@@ -1118,12 +1118,12 @@ public:
|
||||
|
||||
/** @brief Evaluate the values and derivatives of a hierarchical 1D basis at
|
||||
point @a x. */
|
||||
static void CalcBasis(const int p, const double x, Vector &u, Vector &d)
|
||||
static void CalcBasis(const int p, const real_t x, Vector &u, Vector &d)
|
||||
{ CalcBasis(p, x, u.GetData(), d.GetData()); }
|
||||
|
||||
/// Evaluate the values, derivatives and second derivatives of a hierarchical 1D basis at point x
|
||||
static void CalcBasis(const int p, const double x, double *u, double *d,
|
||||
double *dd)
|
||||
static void CalcBasis(const int p, const real_t x, real_t *u, real_t *d,
|
||||
real_t *dd)
|
||||
// { CalcMono(p, x, u, d); }
|
||||
// { CalcBernstein(p, x, u, d); }
|
||||
// { CalcLegendre(p, x, u, d); }
|
||||
@@ -1131,59 +1131,59 @@ public:
|
||||
|
||||
/** @brief Evaluate the values, derivatives and second derivatives of a
|
||||
hierarchical 1D basis at point @a x. */
|
||||
static void CalcBasis(const int p, const double x, Vector &u, Vector &d,
|
||||
static void CalcBasis(const int p, const real_t x, Vector &u, Vector &d,
|
||||
Vector &dd)
|
||||
{ CalcBasis(p, x, u.GetData(), d.GetData(), dd.GetData()); }
|
||||
|
||||
/// Evaluate a representation of a Delta function at point x
|
||||
static double CalcDelta(const int p, const double x)
|
||||
{ return pow(x, (double) p); }
|
||||
static real_t CalcDelta(const int p, const real_t x)
|
||||
{ return pow(x, (real_t) p); }
|
||||
|
||||
/** @brief Compute the points for the Chebyshev polynomials of order @a p
|
||||
and place them in the already allocated @a x array. */
|
||||
static void ChebyshevPoints(const int p, double *x);
|
||||
static void ChebyshevPoints(const int p, real_t *x);
|
||||
|
||||
/** @brief Compute the @a p terms in the expansion of the binomial (x + y)^p
|
||||
and store them in the already allocated @a u array. */
|
||||
static void CalcBinomTerms(const int p, const double x, const double y,
|
||||
double *u);
|
||||
static void CalcBinomTerms(const int p, const real_t x, const real_t y,
|
||||
real_t *u);
|
||||
/** @brief Compute the terms in the expansion of the binomial (x + y)^p and
|
||||
their derivatives with respect to x assuming that dy/dx = -1. Store the
|
||||
results in the already allocated @a u and @a d arrays.*/
|
||||
static void CalcBinomTerms(const int p, const double x, const double y,
|
||||
double *u, double *d);
|
||||
static void CalcBinomTerms(const int p, const real_t x, const real_t y,
|
||||
real_t *u, real_t *d);
|
||||
/** @brief Compute the derivatives (w.r.t. x) of the terms in the expansion
|
||||
of the binomial (x + y)^p assuming that dy/dx = -1. Store the results
|
||||
in the already allocated @a d array.*/
|
||||
static void CalcDBinomTerms(const int p, const double x, const double y,
|
||||
double *d);
|
||||
static void CalcDBinomTerms(const int p, const real_t x, const real_t y,
|
||||
real_t *d);
|
||||
|
||||
/** @brief Compute the values of the Bernstein basis functions of order
|
||||
@a p at coordinate @a x and store the results in the already allocated
|
||||
@a u array. */
|
||||
static void CalcBernstein(const int p, const double x, double *u)
|
||||
static void CalcBernstein(const int p, const real_t x, real_t *u)
|
||||
{ CalcBinomTerms(p, x, 1. - x, u); }
|
||||
|
||||
/** @brief Compute the values of the Bernstein basis functions of order
|
||||
@a p at coordinate @a x and store the results in the already allocated
|
||||
@a u array. */
|
||||
static void CalcBernstein(const int p, const double x, Vector &u)
|
||||
static void CalcBernstein(const int p, const real_t x, Vector &u)
|
||||
{ CalcBernstein(p, x, u.GetData()); }
|
||||
|
||||
/** @brief Compute the values and derivatives of the Bernstein basis functions
|
||||
of order @a p at coordinate @a x and store the results in the already allocated
|
||||
@a u and @a d arrays. */
|
||||
static void CalcBernstein(const int p, const double x, double *u, double *d)
|
||||
static void CalcBernstein(const int p, const real_t x, real_t *u, real_t *d)
|
||||
{ CalcBinomTerms(p, x, 1. - x, u, d); }
|
||||
|
||||
/** @brief Compute the values and derivatives of the Bernstein basis
|
||||
functions of order @a p at coordinate @a x and store the results in the
|
||||
already allocated @a u and @a d arrays. */
|
||||
static void CalcBernstein(const int p, const double x, Vector &u, Vector &d)
|
||||
static void CalcBernstein(const int p, const real_t x, Vector &u, Vector &d)
|
||||
{ CalcBernstein(p, x, u.GetData(), d.GetData()); }
|
||||
|
||||
static void CalcLegendre(const int p, const double x, double *u);
|
||||
static void CalcLegendre(const int p, const double x, double *u, double *d);
|
||||
static void CalcLegendre(const int p, const real_t x, real_t *u);
|
||||
static void CalcLegendre(const int p, const real_t x, real_t *u, real_t *d);
|
||||
|
||||
~Poly_1D();
|
||||
};
|
||||
|
||||
+272
-270
File diff suppressed because it is too large
Load Diff
+19
-19
@@ -114,7 +114,7 @@ public:
|
||||
class GaussBiLinear2DFiniteElement : public NodalFiniteElement
|
||||
{
|
||||
private:
|
||||
static const double p[2];
|
||||
static const real_t p[2];
|
||||
|
||||
public:
|
||||
/// Construct the FiniteElement
|
||||
@@ -188,7 +188,7 @@ public:
|
||||
class GaussQuad2DFiniteElement : public NodalFiniteElement
|
||||
{
|
||||
private:
|
||||
static const double p[2];
|
||||
static const real_t p[2];
|
||||
DenseMatrix A;
|
||||
mutable DenseMatrix D;
|
||||
mutable Vector pol;
|
||||
@@ -491,7 +491,7 @@ public:
|
||||
class RT0TriangleFiniteElement : public VectorFiniteElement
|
||||
{
|
||||
private:
|
||||
static const double nk[3][2];
|
||||
static const real_t nk[3][2];
|
||||
|
||||
public:
|
||||
/// Construct the RT0TriangleFiniteElement
|
||||
@@ -520,7 +520,7 @@ public:
|
||||
class RT0QuadFiniteElement : public VectorFiniteElement
|
||||
{
|
||||
private:
|
||||
static const double nk[4][2];
|
||||
static const real_t nk[4][2];
|
||||
|
||||
public:
|
||||
/// Construct the RT0QuadFiniteElement
|
||||
@@ -549,7 +549,7 @@ public:
|
||||
class RT1TriangleFiniteElement : public VectorFiniteElement
|
||||
{
|
||||
private:
|
||||
static const double nk[8][2];
|
||||
static const real_t nk[8][2];
|
||||
|
||||
public:
|
||||
/// Construct the RT1TriangleFiniteElement
|
||||
@@ -578,7 +578,7 @@ public:
|
||||
class RT1QuadFiniteElement : public VectorFiniteElement
|
||||
{
|
||||
private:
|
||||
static const double nk[12][2];
|
||||
static const real_t nk[12][2];
|
||||
|
||||
public:
|
||||
/// Construct the RT1QuadFiniteElement
|
||||
@@ -607,7 +607,7 @@ public:
|
||||
class RT2TriangleFiniteElement : public VectorFiniteElement
|
||||
{
|
||||
private:
|
||||
static const double M[15][15];
|
||||
static const real_t M[15][15];
|
||||
public:
|
||||
/// Construct the RT2TriangleFiniteElement
|
||||
RT2TriangleFiniteElement();
|
||||
@@ -627,9 +627,9 @@ public:
|
||||
class RT2QuadFiniteElement : public VectorFiniteElement
|
||||
{
|
||||
private:
|
||||
static const double nk[24][2];
|
||||
static const double pt[4];
|
||||
static const double dpt[3];
|
||||
static const real_t nk[24][2];
|
||||
static const real_t pt[4];
|
||||
static const real_t dpt[3];
|
||||
|
||||
public:
|
||||
/// Construct the RT2QuadFiniteElement
|
||||
@@ -910,7 +910,7 @@ public:
|
||||
class Nedelec1HexFiniteElement : public VectorFiniteElement
|
||||
{
|
||||
private:
|
||||
static const double tk[12][3];
|
||||
static const real_t tk[12][3];
|
||||
|
||||
public:
|
||||
/// Construct the Nedelec1HexFiniteElement
|
||||
@@ -938,7 +938,7 @@ public:
|
||||
class Nedelec1TetFiniteElement : public VectorFiniteElement
|
||||
{
|
||||
private:
|
||||
static const double tk[6][3];
|
||||
static const real_t tk[6][3];
|
||||
|
||||
public:
|
||||
/// Construct the Nedelec1TetFiniteElement
|
||||
@@ -966,7 +966,7 @@ public:
|
||||
class Nedelec1WdgFiniteElement : public VectorFiniteElement
|
||||
{
|
||||
private:
|
||||
static const double tk[9][3];
|
||||
static const real_t tk[9][3];
|
||||
|
||||
public:
|
||||
/// Construct the Nedelec1WdgFiniteElement
|
||||
@@ -994,7 +994,7 @@ public:
|
||||
class Nedelec1PyrFiniteElement : public VectorFiniteElement
|
||||
{
|
||||
private:
|
||||
static const double tk[8][3];
|
||||
static const real_t tk[8][3];
|
||||
|
||||
public:
|
||||
/// Construct the Nedelec1PyrFiniteElement
|
||||
@@ -1022,7 +1022,7 @@ public:
|
||||
class RT0HexFiniteElement : public VectorFiniteElement
|
||||
{
|
||||
private:
|
||||
static const double nk[6][3];
|
||||
static const real_t nk[6][3];
|
||||
|
||||
public:
|
||||
/// Construct the RT0HexFiniteElement
|
||||
@@ -1052,7 +1052,7 @@ public:
|
||||
class RT1HexFiniteElement : public VectorFiniteElement
|
||||
{
|
||||
private:
|
||||
static const double nk[36][3];
|
||||
static const real_t nk[36][3];
|
||||
|
||||
public:
|
||||
/// Construct the RT1HexFiniteElement
|
||||
@@ -1082,7 +1082,7 @@ public:
|
||||
class RT0TetFiniteElement : public VectorFiniteElement
|
||||
{
|
||||
private:
|
||||
static const double nk[4][3];
|
||||
static const real_t nk[4][3];
|
||||
|
||||
public:
|
||||
/// Construct the RT0TetFiniteElement
|
||||
@@ -1112,7 +1112,7 @@ public:
|
||||
class RT0WdgFiniteElement : public VectorFiniteElement
|
||||
{
|
||||
private:
|
||||
static const double nk[5][3];
|
||||
static const real_t nk[5][3];
|
||||
|
||||
public:
|
||||
/// Construct the RT0WdgFiniteElement
|
||||
@@ -1146,7 +1146,7 @@ public:
|
||||
class RT0PyrFiniteElement : public VectorFiniteElement
|
||||
{
|
||||
private:
|
||||
static const double nk[5][3];
|
||||
static const real_t nk[5][3];
|
||||
|
||||
// If true match RT0TetFiniteElement rather than RT_TetrahedronElement(0)
|
||||
bool rt0;
|
||||
|
||||
+14
-14
@@ -21,7 +21,7 @@ using namespace std;
|
||||
H1_SegmentElement::H1_SegmentElement(const int p, const int btype)
|
||||
: NodalTensorFiniteElement(1, p, VerifyClosed(btype), H1_DOF_MAP)
|
||||
{
|
||||
const double *cp = poly1d.ClosedPoints(p, b_type);
|
||||
const real_t *cp = poly1d.ClosedPoints(p, b_type);
|
||||
|
||||
#ifndef MFEM_THREAD_SAFE
|
||||
shape_x.SetSize(p+1);
|
||||
@@ -97,7 +97,7 @@ void H1_SegmentElement::CalcHessian(const IntegrationPoint &ip,
|
||||
void H1_SegmentElement::ProjectDelta(int vertex, Vector &dofs) const
|
||||
{
|
||||
const int p = order;
|
||||
const double *cp = poly1d.ClosedPoints(p, b_type);
|
||||
const real_t *cp = poly1d.ClosedPoints(p, b_type);
|
||||
|
||||
switch (vertex)
|
||||
{
|
||||
@@ -125,7 +125,7 @@ void H1_SegmentElement::ProjectDelta(int vertex, Vector &dofs) const
|
||||
H1_QuadrilateralElement::H1_QuadrilateralElement(const int p, const int btype)
|
||||
: NodalTensorFiniteElement(2, p, VerifyClosed(btype), H1_DOF_MAP)
|
||||
{
|
||||
const double *cp = poly1d.ClosedPoints(p, b_type);
|
||||
const real_t *cp = poly1d.ClosedPoints(p, b_type);
|
||||
|
||||
#ifndef MFEM_THREAD_SAFE
|
||||
const int p1 = p + 1;
|
||||
@@ -216,7 +216,7 @@ void H1_QuadrilateralElement::CalcHessian(const IntegrationPoint &ip,
|
||||
void H1_QuadrilateralElement::ProjectDelta(int vertex, Vector &dofs) const
|
||||
{
|
||||
const int p = order;
|
||||
const double *cp = poly1d.ClosedPoints(p, b_type);
|
||||
const real_t *cp = poly1d.ClosedPoints(p, b_type);
|
||||
|
||||
#ifdef MFEM_THREAD_SAFE
|
||||
Vector shape_x(p+1), shape_y(p+1);
|
||||
@@ -265,7 +265,7 @@ void H1_QuadrilateralElement::ProjectDelta(int vertex, Vector &dofs) const
|
||||
H1_HexahedronElement::H1_HexahedronElement(const int p, const int btype)
|
||||
: NodalTensorFiniteElement(3, p, VerifyClosed(btype), H1_DOF_MAP)
|
||||
{
|
||||
const double *cp = poly1d.ClosedPoints(p, b_type);
|
||||
const real_t *cp = poly1d.ClosedPoints(p, b_type);
|
||||
|
||||
#ifndef MFEM_THREAD_SAFE
|
||||
const int p1 = p + 1;
|
||||
@@ -367,7 +367,7 @@ void H1_HexahedronElement::CalcHessian(const IntegrationPoint &ip,
|
||||
void H1_HexahedronElement::ProjectDelta(int vertex, Vector &dofs) const
|
||||
{
|
||||
const int p = order;
|
||||
const double *cp = poly1d.ClosedPoints(p,b_type);
|
||||
const real_t *cp = poly1d.ClosedPoints(p,b_type);
|
||||
|
||||
#ifdef MFEM_THREAD_SAFE
|
||||
Vector shape_x(p+1), shape_y(p+1);
|
||||
@@ -452,7 +452,7 @@ H1_TriangleElement::H1_TriangleElement(const int p, const int btype)
|
||||
: NodalFiniteElement(2, Geometry::TRIANGLE, ((p + 1)*(p + 2))/2, p,
|
||||
FunctionSpace::Pk)
|
||||
{
|
||||
const double *cp = poly1d.ClosedPoints(p, VerifyNodal(VerifyClosed(btype)));
|
||||
const real_t *cp = poly1d.ClosedPoints(p, VerifyNodal(VerifyClosed(btype)));
|
||||
|
||||
#ifndef MFEM_THREAD_SAFE
|
||||
shape_x.SetSize(p + 1);
|
||||
@@ -505,7 +505,7 @@ H1_TriangleElement::H1_TriangleElement(const int p, const int btype)
|
||||
for (int j = 1; j < p; j++)
|
||||
for (int i = 1; i + j < p; i++)
|
||||
{
|
||||
const double w = cp[i] + cp[j] + cp[p-i-j];
|
||||
const real_t w = cp[i] + cp[j] + cp[p-i-j];
|
||||
lex_ordering[idx(i,j)] = o;
|
||||
Nodes.IntPoint(o++).Set2(cp[i]/w, cp[j]/w);
|
||||
}
|
||||
@@ -618,7 +618,7 @@ H1_TetrahedronElement::H1_TetrahedronElement(const int p, const int btype)
|
||||
: NodalFiniteElement(3, Geometry::TETRAHEDRON, ((p + 1)*(p + 2)*(p + 3))/6,
|
||||
p, FunctionSpace::Pk)
|
||||
{
|
||||
const double *cp = poly1d.ClosedPoints(p, VerifyNodal(VerifyClosed(btype)));
|
||||
const real_t *cp = poly1d.ClosedPoints(p, VerifyNodal(VerifyClosed(btype)));
|
||||
|
||||
#ifndef MFEM_THREAD_SAFE
|
||||
shape_x.SetSize(p + 1);
|
||||
@@ -698,28 +698,28 @@ H1_TetrahedronElement::H1_TetrahedronElement(const int p, const int btype)
|
||||
for (int i = 1; i + j < p; i++) // (1,2,3)
|
||||
{
|
||||
lex_ordering[idx(p-i-j,i,j)] = o;
|
||||
double w = cp[i] + cp[j] + cp[p-i-j];
|
||||
real_t w = cp[i] + cp[j] + cp[p-i-j];
|
||||
Nodes.IntPoint(o++).Set3(cp[p-i-j]/w, cp[i]/w, cp[j]/w);
|
||||
}
|
||||
for (int j = 1; j < p; j++)
|
||||
for (int i = 1; i + j < p; i++) // (0,3,2)
|
||||
{
|
||||
lex_ordering[idx(0,j,i)] = o;
|
||||
double w = cp[i] + cp[j] + cp[p-i-j];
|
||||
real_t w = cp[i] + cp[j] + cp[p-i-j];
|
||||
Nodes.IntPoint(o++).Set3(cp[0], cp[j]/w, cp[i]/w);
|
||||
}
|
||||
for (int j = 1; j < p; j++)
|
||||
for (int i = 1; i + j < p; i++) // (0,1,3)
|
||||
{
|
||||
lex_ordering[idx(i,0,j)] = o;
|
||||
double w = cp[i] + cp[j] + cp[p-i-j];
|
||||
real_t w = cp[i] + cp[j] + cp[p-i-j];
|
||||
Nodes.IntPoint(o++).Set3(cp[i]/w, cp[0], cp[j]/w);
|
||||
}
|
||||
for (int j = 1; j < p; j++)
|
||||
for (int i = 1; i + j < p; i++) // (0,2,1)
|
||||
{
|
||||
lex_ordering[idx(j,i,0)] = o;
|
||||
double w = cp[i] + cp[j] + cp[p-i-j];
|
||||
real_t w = cp[i] + cp[j] + cp[p-i-j];
|
||||
Nodes.IntPoint(o++).Set3(cp[j]/w, cp[i]/w, cp[0]);
|
||||
}
|
||||
|
||||
@@ -729,7 +729,7 @@ H1_TetrahedronElement::H1_TetrahedronElement(const int p, const int btype)
|
||||
for (int i = 1; i + j + k < p; i++)
|
||||
{
|
||||
lex_ordering[idx(i,j,k)] = o;
|
||||
double w = cp[i] + cp[j] + cp[k] + cp[p-i-j-k];
|
||||
real_t w = cp[i] + cp[j] + cp[k] + cp[p-i-j-k];
|
||||
Nodes.IntPoint(o++).Set3(cp[i]/w, cp[j]/w, cp[k]/w);
|
||||
}
|
||||
|
||||
|
||||
+35
-35
@@ -23,7 +23,7 @@ using namespace std;
|
||||
L2_SegmentElement::L2_SegmentElement(const int p, const int btype)
|
||||
: NodalTensorFiniteElement(1, p, VerifyOpen(btype), L2_DOF_MAP)
|
||||
{
|
||||
const double *op = poly1d.OpenPoints(p, btype);
|
||||
const real_t *op = poly1d.OpenPoints(p, btype);
|
||||
|
||||
#ifndef MFEM_THREAD_SAFE
|
||||
shape_x.SetSize(p + 1);
|
||||
@@ -58,7 +58,7 @@ void L2_SegmentElement::CalcDShape(const IntegrationPoint &ip,
|
||||
void L2_SegmentElement::ProjectDelta(int vertex, Vector &dofs) const
|
||||
{
|
||||
const int p = order;
|
||||
const double *op = poly1d.OpenPoints(p, b_type);
|
||||
const real_t *op = poly1d.OpenPoints(p, b_type);
|
||||
|
||||
switch (vertex)
|
||||
{
|
||||
@@ -82,7 +82,7 @@ void L2_SegmentElement::ProjectDelta(int vertex, Vector &dofs) const
|
||||
L2_QuadrilateralElement::L2_QuadrilateralElement(const int p, const int btype)
|
||||
: NodalTensorFiniteElement(2, p, VerifyOpen(btype), L2_DOF_MAP)
|
||||
{
|
||||
const double *op = poly1d.OpenPoints(p, b_type);
|
||||
const real_t *op = poly1d.OpenPoints(p, b_type);
|
||||
|
||||
#ifndef MFEM_THREAD_SAFE
|
||||
shape_x.SetSize(p + 1);
|
||||
@@ -142,7 +142,7 @@ void L2_QuadrilateralElement::CalcDShape(const IntegrationPoint &ip,
|
||||
void L2_QuadrilateralElement::ProjectDelta(int vertex, Vector &dofs) const
|
||||
{
|
||||
const int p = order;
|
||||
const double *op = poly1d.OpenPoints(p, b_type);
|
||||
const real_t *op = poly1d.OpenPoints(p, b_type);
|
||||
|
||||
#ifdef MFEM_THREAD_SAFE
|
||||
Vector shape_x(p+1), shape_y(p+1);
|
||||
@@ -200,16 +200,16 @@ void L2_QuadrilateralElement::ProjectDiv(const FiniteElement &fe,
|
||||
div = 0.0;
|
||||
|
||||
const IntegrationRule &ir = IntRules.Get(geom_type, fe.GetOrder());
|
||||
const double *gll_pts = poly1d.GetPoints(order+1, BasisType::GaussLobatto);
|
||||
const real_t *gll_pts = poly1d.GetPoints(order+1, BasisType::GaussLobatto);
|
||||
|
||||
// Loop over subcells
|
||||
for (int iy = 0; iy < order+1; ++iy)
|
||||
{
|
||||
const double hy = gll_pts[iy+1] - gll_pts[iy];
|
||||
const real_t hy = gll_pts[iy+1] - gll_pts[iy];
|
||||
for (int ix = 0; ix < order+1; ++ix)
|
||||
{
|
||||
const int i = ix + iy*(order+1);
|
||||
const double hx = gll_pts[ix+1] - gll_pts[ix];
|
||||
const real_t hx = gll_pts[ix+1] - gll_pts[ix];
|
||||
// Loop over subcell quadrature points
|
||||
for (int iq = 0; iq < ir.Size(); ++iq)
|
||||
{
|
||||
@@ -218,10 +218,10 @@ void L2_QuadrilateralElement::ProjectDiv(const FiniteElement &fe,
|
||||
ip.y = gll_pts[iy] + hy*ip.y;
|
||||
Trans.SetIntPoint(&ip);
|
||||
fe.CalcDivShape(ip, div_shape);
|
||||
double w = ip.weight;
|
||||
real_t w = ip.weight;
|
||||
if (map_type == VALUE)
|
||||
{
|
||||
const double detJ = Trans.Weight();
|
||||
const real_t detJ = Trans.Weight();
|
||||
w /= detJ;
|
||||
}
|
||||
else if (map_type == INTEGRAL)
|
||||
@@ -230,7 +230,7 @@ void L2_QuadrilateralElement::ProjectDiv(const FiniteElement &fe,
|
||||
}
|
||||
for (int j = 0; j < fe_ndof; j++)
|
||||
{
|
||||
const double div_j = div_shape(j);
|
||||
const real_t div_j = div_shape(j);
|
||||
div(i,j) += w*div_j;
|
||||
}
|
||||
}
|
||||
@@ -259,17 +259,17 @@ void L2_QuadrilateralElement::Project(Coefficient &coeff,
|
||||
if (basis1d.IsIntegratedType())
|
||||
{
|
||||
const IntegrationRule &ir = IntRules.Get(geom_type, order);
|
||||
const double *gll_pts = poly1d.GetPoints(order+1, BasisType::GaussLobatto);
|
||||
const real_t *gll_pts = poly1d.GetPoints(order+1, BasisType::GaussLobatto);
|
||||
|
||||
dofs = 0.0;
|
||||
// Loop over subcells
|
||||
for (int iy = 0; iy < order+1; ++iy)
|
||||
{
|
||||
const double hy = gll_pts[iy+1] - gll_pts[iy];
|
||||
const real_t hy = gll_pts[iy+1] - gll_pts[iy];
|
||||
for (int ix = 0; ix < order+1; ++ix)
|
||||
{
|
||||
const int i = ix + iy*(order+1);
|
||||
const double hx = gll_pts[ix+1] - gll_pts[ix];
|
||||
const real_t hx = gll_pts[ix+1] - gll_pts[ix];
|
||||
// Loop over subcell quadrature points
|
||||
for (int iq = 0; iq < ir.Size(); ++iq)
|
||||
{
|
||||
@@ -277,8 +277,8 @@ void L2_QuadrilateralElement::Project(Coefficient &coeff,
|
||||
ip.x = gll_pts[ix] + hx*ip.x;
|
||||
ip.y = gll_pts[iy] + hy*ip.y;
|
||||
Trans.SetIntPoint(&ip);
|
||||
const double val = coeff.Eval(Trans, ip);
|
||||
double w = ip.weight;
|
||||
const real_t val = coeff.Eval(Trans, ip);
|
||||
real_t w = ip.weight;
|
||||
if (map_type == INTEGRAL)
|
||||
{
|
||||
w *= hx*hy*Trans.Weight();
|
||||
@@ -298,7 +298,7 @@ void L2_QuadrilateralElement::Project(Coefficient &coeff,
|
||||
L2_HexahedronElement::L2_HexahedronElement(const int p, const int btype)
|
||||
: NodalTensorFiniteElement(3, p, VerifyOpen(btype), L2_DOF_MAP)
|
||||
{
|
||||
const double *op = poly1d.OpenPoints(p, btype);
|
||||
const real_t *op = poly1d.OpenPoints(p, btype);
|
||||
|
||||
#ifndef MFEM_THREAD_SAFE
|
||||
shape_x.SetSize(p + 1);
|
||||
@@ -367,7 +367,7 @@ void L2_HexahedronElement::CalcDShape(const IntegrationPoint &ip,
|
||||
void L2_HexahedronElement::ProjectDelta(int vertex, Vector &dofs) const
|
||||
{
|
||||
const int p = order;
|
||||
const double *op = poly1d.OpenPoints(p, b_type);
|
||||
const real_t *op = poly1d.OpenPoints(p, b_type);
|
||||
|
||||
#ifdef MFEM_THREAD_SAFE
|
||||
Vector shape_x(p+1), shape_y(p+1);
|
||||
@@ -461,19 +461,19 @@ void L2_HexahedronElement::ProjectDiv(const FiniteElement &fe,
|
||||
div = 0.0;
|
||||
|
||||
const IntegrationRule &ir = IntRules.Get(geom_type, fe.GetOrder());
|
||||
const double *gll_pts = poly1d.GetPoints(order+1, BasisType::GaussLobatto);
|
||||
const real_t *gll_pts = poly1d.GetPoints(order+1, BasisType::GaussLobatto);
|
||||
|
||||
// Loop over subcells
|
||||
for (int iz = 0; iz < order+1; ++iz)
|
||||
{
|
||||
const double hz = gll_pts[iz+1] - gll_pts[iz];
|
||||
const real_t hz = gll_pts[iz+1] - gll_pts[iz];
|
||||
for (int iy = 0; iy < order+1; ++iy)
|
||||
{
|
||||
const double hy = gll_pts[iy+1] - gll_pts[iy];
|
||||
const real_t hy = gll_pts[iy+1] - gll_pts[iy];
|
||||
for (int ix = 0; ix < order+1; ++ix)
|
||||
{
|
||||
const int i = ix + iy*(order+1) + iz*(order+1)*(order+1);
|
||||
const double hx = gll_pts[ix+1] - gll_pts[ix];
|
||||
const real_t hx = gll_pts[ix+1] - gll_pts[ix];
|
||||
// Loop over subcell quadrature points
|
||||
for (int iq = 0; iq < ir.Size(); ++iq)
|
||||
{
|
||||
@@ -483,10 +483,10 @@ void L2_HexahedronElement::ProjectDiv(const FiniteElement &fe,
|
||||
ip.z = gll_pts[iz] + hz*ip.z;
|
||||
Trans.SetIntPoint(&ip);
|
||||
fe.CalcDivShape(ip, div_shape);
|
||||
double w = ip.weight;
|
||||
real_t w = ip.weight;
|
||||
if (map_type == VALUE)
|
||||
{
|
||||
const double detJ = Trans.Weight();
|
||||
const real_t detJ = Trans.Weight();
|
||||
w /= detJ;
|
||||
}
|
||||
else if (map_type == INTEGRAL)
|
||||
@@ -495,7 +495,7 @@ void L2_HexahedronElement::ProjectDiv(const FiniteElement &fe,
|
||||
}
|
||||
for (int j = 0; j < fe_ndof; j++)
|
||||
{
|
||||
const double div_j = div_shape(j);
|
||||
const real_t div_j = div_shape(j);
|
||||
div(i,j) += w*div_j;
|
||||
}
|
||||
}
|
||||
@@ -525,19 +525,19 @@ void L2_HexahedronElement::Project(Coefficient &coeff,
|
||||
if (basis1d.IsIntegratedType())
|
||||
{
|
||||
const IntegrationRule &ir = IntRules.Get(geom_type, order);
|
||||
const double *gll_pts = poly1d.GetPoints(order+1, BasisType::GaussLobatto);
|
||||
const real_t *gll_pts = poly1d.GetPoints(order+1, BasisType::GaussLobatto);
|
||||
|
||||
dofs = 0.0;
|
||||
// Loop over subcells
|
||||
for (int iz = 0; iz < order+1; ++iz)
|
||||
{
|
||||
const double hz = gll_pts[iz+1] - gll_pts[iz];
|
||||
const real_t hz = gll_pts[iz+1] - gll_pts[iz];
|
||||
for (int iy = 0; iy < order+1; ++iy)
|
||||
{
|
||||
const double hy = gll_pts[iy+1] - gll_pts[iy];
|
||||
const real_t hy = gll_pts[iy+1] - gll_pts[iy];
|
||||
for (int ix = 0; ix < order+1; ++ix)
|
||||
{
|
||||
const double hx = gll_pts[ix+1] - gll_pts[ix];
|
||||
const real_t hx = gll_pts[ix+1] - gll_pts[ix];
|
||||
const int i = ix + iy*(order+1) + iz*(order+1)*(order+1);
|
||||
// Loop over subcell quadrature points
|
||||
for (int iq = 0; iq < ir.Size(); ++iq)
|
||||
@@ -547,11 +547,11 @@ void L2_HexahedronElement::Project(Coefficient &coeff,
|
||||
ip.y = gll_pts[iy] + hy*ip.y;
|
||||
ip.z = gll_pts[iz] + hz*ip.z;
|
||||
Trans.SetIntPoint(&ip);
|
||||
const double val = coeff.Eval(Trans, ip);
|
||||
double w = ip.weight;
|
||||
const real_t val = coeff.Eval(Trans, ip);
|
||||
real_t w = ip.weight;
|
||||
if (map_type == INTEGRAL)
|
||||
{
|
||||
const double detJ = Trans.Weight();
|
||||
const real_t detJ = Trans.Weight();
|
||||
w *= detJ*hx*hy*hz;
|
||||
}
|
||||
dofs[i] += val*w;
|
||||
@@ -571,7 +571,7 @@ L2_TriangleElement::L2_TriangleElement(const int p, const int btype)
|
||||
: NodalFiniteElement(2, Geometry::TRIANGLE, ((p + 1)*(p + 2))/2, p,
|
||||
FunctionSpace::Pk)
|
||||
{
|
||||
const double *op = poly1d.OpenPoints(p, VerifyOpen(btype));
|
||||
const real_t *op = poly1d.OpenPoints(p, VerifyOpen(btype));
|
||||
|
||||
#ifndef MFEM_THREAD_SAFE
|
||||
shape_x.SetSize(p + 1);
|
||||
@@ -589,7 +589,7 @@ L2_TriangleElement::L2_TriangleElement(const int p, const int btype)
|
||||
for (int o = 0, j = 0; j <= p; j++)
|
||||
for (int i = 0; i + j <= p; i++)
|
||||
{
|
||||
double w = op[i] + op[j] + op[p-i-j];
|
||||
real_t w = op[i] + op[j] + op[p-i-j];
|
||||
Nodes.IntPoint(o++).Set2(op[i]/w, op[j]/w);
|
||||
}
|
||||
|
||||
@@ -696,7 +696,7 @@ L2_TetrahedronElement::L2_TetrahedronElement(const int p, const int btype)
|
||||
: NodalFiniteElement(3, Geometry::TETRAHEDRON, ((p + 1)*(p + 2)*(p + 3))/6,
|
||||
p, FunctionSpace::Pk)
|
||||
{
|
||||
const double *op = poly1d.OpenPoints(p, VerifyOpen(btype));
|
||||
const real_t *op = poly1d.OpenPoints(p, VerifyOpen(btype));
|
||||
|
||||
#ifndef MFEM_THREAD_SAFE
|
||||
shape_x.SetSize(p + 1);
|
||||
@@ -717,7 +717,7 @@ L2_TetrahedronElement::L2_TetrahedronElement(const int p, const int btype)
|
||||
for (int j = 0; j + k <= p; j++)
|
||||
for (int i = 0; i + j + k <= p; i++)
|
||||
{
|
||||
double w = op[i] + op[j] + op[k] + op[p-i-j-k];
|
||||
real_t w = op[i] + op[j] + op[k] + op[p-i-j-k];
|
||||
Nodes.IntPoint(o++).Set3(op[i]/w, op[j]/w, op[k]/w);
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user