v0.16.0
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
PhotonDiffusion::OpError Struct Reference
Inheritance diagram for PhotonDiffusion::OpError:
[legend]
Collaboration diagram for PhotonDiffusion::OpError:
[legend]

Public Member Functions

 OpError (boost::shared_ptr< CommonData > &common_data_ptr)
 
MoFEMErrorCode doWork (int side, EntityType type, EntData &data)
 
 OpError (boost::shared_ptr< CommonData > &common_data_ptr)
 
MoFEMErrorCode doWork (int side, EntityType type, EntData &data)
 

Static Public Member Functions

static double sourceFunction (const double x, const double y, const double z, double time)
 

Public Attributes

boost::shared_ptr< CommonDatacommonDataPtr
 

Detailed Description

Definition at line 110 of file initial_diffusion.cpp.

Constructor & Destructor Documentation

◆ OpError() [1/2]

PhotonDiffusion::OpError::OpError ( boost::shared_ptr< CommonData > &  common_data_ptr)
inline

Definition at line 113 of file initial_diffusion.cpp.

114 : DomainEleOp("PHOTON_FLUENCE_RATE", OPROW),
115 commonDataPtr(common_data_ptr) {}
DomainEle::UserDataOperator DomainEleOp
boost::shared_ptr< CommonData > commonDataPtr

◆ OpError() [2/2]

PhotonDiffusion::OpError::OpError ( boost::shared_ptr< CommonData > &  common_data_ptr)
inline

Definition at line 283 of file photon_diffusion.cpp.

284 : BoundaryEleOp("PHOTON_FLUENCE_RATE", OPROW),
285 commonDataPtr(common_data_ptr) {}
BoundaryEle::UserDataOperator BoundaryEleOp

Member Function Documentation

◆ doWork() [1/2]

MoFEMErrorCode PhotonDiffusion::OpError::doWork ( int  side,
EntityType  type,
EntData data 
)
inline

Definition at line 117 of file initial_diffusion.cpp.

117 {
119
120 if (const size_t nb_dofs = data.getIndices().size()) {
121
122 const int nb_integration_pts = getGaussPts().size2();
123 auto t_w = getFTensor0IntegrationWeight();
124 auto t_val = getFTensor0FromVec(*(commonDataPtr->uAtPtsPtr));
125 auto t_coords = getFTensor1CoordsAtGaussPts();
126
127 VectorDouble nf(nb_dofs, false);
128 nf.clear();
129
130 FTensor::Index<'i', 3> i;
131 const double volume = getMeasure();
132
133 auto t_row_base = data.getFTensor0N();
134 double error = 0;
135 for (int gg = 0; gg != nb_integration_pts; ++gg) {
136
137 const double alpha = t_w * volume;
138 double diff = t_val - PhotonDiffusion::sourceFunction(
139 t_coords(0), t_coords(1), t_coords(2));
140
141 error += alpha * pow(diff, 2);
142
143 for (size_t r = 0; r != nb_dofs; ++r) {
144 nf[r] += alpha * t_row_base * diff;
145 ++t_row_base;
146 }
147
148 ++t_w;
149 ++t_val;
150 ++t_coords;
151 }
152
153 const int index = 0;
154 CHKERR VecSetValue(commonDataPtr->L2Vec, index, error, ADD_VALUES);
155 CHKERR VecSetValues(commonDataPtr->resVec, data, &nf[0], ADD_VALUES);
156 }
157
159 }
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define CHKERR
Inline error check.
FTensor::Index< 'i', SPACE_DIM > i
static auto getFTensor0FromVec(V &data)
Get tensor rank 0 (scalar) form data vector.
MoFEMErrorCode VecSetValues(Vec V, const EntitiesFieldData::EntData &data, const double *ptr, InsertMode iora)
Assemble PETSc vector.
int r
Definition sdf.py:205
FTensor::Tensor0< FTensor::PackPtr< double *, 1 > > getFTensor0N(const FieldApproximationBase base)
Get base function as Tensor0.
const VectorInt & getIndices() const
Get global indices of degrees of freedom on entity.
static double sourceFunction(const double x, const double y, const double z)

◆ doWork() [2/2]

MoFEMErrorCode PhotonDiffusion::OpError::doWork ( int  side,
EntityType  type,
EntData data 
)
inline

Definition at line 287 of file photon_diffusion.cpp.

287 {
289 const int nb_integration_pts = getGaussPts().size2();
290 auto t_w = getFTensor0IntegrationWeight();
291 auto t_val = getFTensor0FromVec(*(commonDataPtr->uAtPtsPtr));
292 auto t_coords = getFTensor1CoordsAtGaussPts();
293
294 double nf = 1;
295
296 FTensor::Index<'i', 3> i;
297 const double volume = getMeasure();
298
299 double error = 0;
300 for (int gg = 0; gg != nb_integration_pts; ++gg) {
301
302 const double alpha = t_w * volume;
303 double analytical =
304 sourceFunction(t_coords(0), t_coords(1), slab_thickness / 2, 0.01);
305 double diff = t_val - analytical;
306
307 error += alpha * pow(diff, 2) / std::abs(t_val);
308
309 ++t_w;
310 ++t_val;
311 ++t_coords;
312 }
313
314 const int index = 0;
315
316 CHKERR VecSetValue(commonDataPtr->L2Vec, index, error / nb_integration_pts,
317 ADD_VALUES);
318 CHKERR VecSetValue(commonDataPtr->resVec, index, nf, ADD_VALUES);
319
321 }
double slab_thickness
static double sourceFunction(const double x, const double y, const double z, double time)

◆ sourceFunction()

static double PhotonDiffusion::OpError::sourceFunction ( const double  x,
const double  y,
const double  z,
double  time 
)
inlinestatic

Definition at line 276 of file photon_diffusion.cpp.

277 {
280 mu_a, mu_sp, flux_magnitude, time, v, D);
281 };
double sourceFunctionEval(const double x, const double y, const double z, const double beam_radius, const double beam_centre_x, const double beam_centre_y, const double slab_thickness, const double mu_a, const double mu_sp, const double flux_magnitude, double initial_time, const double v, const double D)
Pulse is infinitely short.
double mu_sp
scattering coefficient (cm^-1)
double flux_magnitude
impulse magnitude
double beam_centre_y
double beam_centre_x
double beam_radius
double D
double mu_a
absorption coefficient (cm^-1)
const double v
phase velocity of light in medium (cm/ns)

Member Data Documentation

◆ commonDataPtr

boost::shared_ptr< CommonData > PhotonDiffusion::OpError::commonDataPtr

Definition at line 111 of file initial_diffusion.cpp.


The documentation for this struct was generated from the following files: