9#include <util/math/Constants.h>
33 read(in,
"mode", mode_);
34 if (mode_ == Planar) {
42 read(in,
"xMax", xMax_);
44 dx_ = (xMax_ - xMin_)/
double(nx_ - 1);
55 dx_ = (xMax_ - xMin_)/
double(nx_ - 1);
60 double xMin,
double xMax,
int nx)
67 dx_ = (xMax_ - xMin_)/
double(nx_ - 1);
78 dx_ = xMax_/double(nx_ - 1);
89 dx_ = xMax_/double(nx_ - 1);
93 void Domain::computeVolume()
95 if (mode_ == Planar) {
96 volume_ = xMax_ - xMin_;
98 if (mode_ == Cylindrical) {
99 volume_ = xMax_*xMax_;
101 volume_ -= xMin_*xMin_;
105 if (mode_ == Spherical) {
106 volume_ = xMax_*xMax_*xMax_;
108 volume_ -= xMin_*xMin_*xMin_;
128 if (mode_ == Planar) {
131 for (
int i = 1; i < nx_ - 1; ++i) {
134 sum += 0.5*f[nx_ - 1];
135 norm = double(nx_ - 1);
138 if (mode_ == Cylindrical) {
140 double x0 = xMin_/dx_;
153 for (
int i = 1; i < nx_ - 1; ++i) {
160 x = x0 + double(nx_-1);
161 sum += 0.5*x*f[nx_-1];
165 if (mode_ == Spherical) {
167 double x0 = xMin_/dx_;
171 sum += 0.5*x0*x0*f[0];
180 for (
int i = 1; i < nx_ - 1; ++i) {
187 x = x0 + double(nx_-1);
188 sum += 0.5*x*x*f[nx_-1];
214 for (
int i = 0; i < nx_; ++i) {
215 work_[i] = f[i]*g[i];
double spatialAverage(Field const &f) const
Compute spatial average of a field.
void setSphereParameters(double xMax, int nx)
Set grid parameters for a sphere.
double xMin() const
Get minimum spatial coordinate.
void setShellParameters(GeometryMode mode, double xMin, double xMax, int nx)
Set grid parameters for a cylindrical or spherical shell.
double xMax() const
Get maximum spatial coordinate.
void setPlanarParameters(double xMin, double xMax, int nx)
Set grid parameters for a planar domain.
GeometryMode const & mode() const
Get coordinate system flag (Planar, Cylindrical or Spherical).
void readParameters(std::istream &in)
Read all parameters and initialize.
int nx() const
Get number of spatial grid points, including both endpoints.
void setCylinderParameters(double xMax, int nx)
Set grid parameters for a cylinder.
double innerProduct(Field const &f, Field const &g) const
Compute inner product of two real fields.
int capacity() const
Return allocated size.
static const double Pi
Trigonometric constant Pi.
void allocate(int capacity)
Allocate the underlying C array.
bool isAllocated() const
Return true if this DArray has been allocated, false otherwise.
ScalarParam< Type > & read(std::istream &in, const char *label, Type &value)
Add and read a new required ScalarParam < Type > object.
void setClassName(const char *className)
Set class name string.
ScalarParam< Type > & readOptional(std::istream &in, const char *label, Type &value)
Add and read a new optional ScalarParam < Type > object.
#define UTIL_CHECK(condition)
Assertion macro suitable for serial or parallel production code.
#define UTIL_THROW(msg)
Macro for throwing an Exception, reporting function, file and line number.
#define UTIL_ASSERT(condition)
Assertion macro suitable for debugging serial or parallel code.
GeometryMode
Enumeration of geometrical modes for functions of one coordinate.
C++ namespace for polymer self-consistent field theory (PSCF).