v0.10.0
Classes | Enumerations | Functions | Variables
AnalyticalSolutions.hpp File Reference

Go to the source code of this file.

Classes

struct  GenericAnalyticalSolution
 Generic structure for analytical function. More...
 
struct  IncidentWave
 
struct  IncidentWavePointSource
 
struct  HardSphereScatterWave
 
struct  SoftSphereScatterWave
 
struct  PlaneWave
 Calculate the analytical solution of plane wave guide propagating in direction theta

\[ p_\textrm{scattered} = exp^{ik\mathbf{x}\Theta} \]

. More...

 
struct  HardCylinderScatterWave
 Calculate the analytical solution of impinging wave on cylinder

\[ p_\textrm{scattered} = \sum_0^N A_l H_l(kr)\cos(l\theta) \]

. More...

 
struct  SoftCylinderScatterWave
 Calculate the analytical solution of impinging wave on cylinder

\[ p_\textrm{scattered} = \sum_0^N A_l H_l(kr)\cos(l\theta) \]

. More...

 
struct  SingularScatterWave
 
struct  SingularIncidentWave
 

Enumerations

enum  AnalyticalSolutionTypes {
  HARD_SPHERE_SCATTER_WAVE, SOFT_SPHERE_SCATTER_WAVE, PLANE_WAVE, HARD_CYLINDER_SCATTER_WAVE,
  SOFT_CYLINDER_SCATTER_WAVE, SINGULAR_SCATTER_WAVE, INCIDENT_WAVE, NO_ANALYTICAL_SOLUTION,
  HARD_SPHERE_SCATTER_WAVE, SOFT_SPHERE_SCATTER_WAVE, PLANE_WAVE, HARD_CYLINDER_SCATTER_WAVE,
  SOFT_CYLINDER_SCATTER_WAVE, INCIDENT_WAVE
}
 

Functions

template<typename FUNVAL >
PetscErrorCode calculate_matrix_and_vector (MoFEM::Interface &m_field, const string &problem_name, const string &fe_name, const string &re_field, Mat A, vector< Vec > vec_F, FUNVAL &fun_evaluator)
 
PetscErrorCode save_data_on_mesh (MoFEM::Interface &m_field, const string &problem_name, const string &re_field, const string &im_field, Vec D, int vt, InsertMode mode, PetscBool is_partitioned)
 
template<typename FUNEVAL >
PetscErrorCode solve_problem (MoFEM::Interface &m_field, const string &problem_name, const string &fe_name, const string &re_field, const string &im_field, InsertMode mode, FUNEVAL &fun_evaluator, PetscBool is_partitioned)
 

Variables

const char * analytical_solution_types []
 

Detailed Description

Analytical solutions

Definition in file AnalyticalSolutions.hpp.

Function Documentation

◆ calculate_matrix_and_vector()

template<typename FUNVAL >
PetscErrorCode calculate_matrix_and_vector ( MoFEM::Interface m_field,
const string &  problem_name,
const string &  fe_name,
const string &  re_field,
Mat  A,
vector< Vec >  vec_F,
FUNVAL &  fun_evaluator 
)

Definition at line 1333 of file AnalyticalSolutions.hpp.

1336  {
1337  PetscFunctionBegin;
1338 
1339  PetscErrorCode ierr;
1340  FieldApproximationH1 field_approximation(m_field);
1341  // This increase rule for numerical integration. In case of 10 node
1342  // elements jacobian is varying linearly across element, that way to element
1343  // rule is add 1.
1344  // field_approximation.addToRule = 1;
1345  // field_approximation.feVolume = HelmholtzElement::MyVolumeFE(m_field,true,1);
1346 
1347  ierr = field_approximation.loopMatrixAndVectorVolume(
1348  problem_name,fe_name,re_field,A,vec_F,fun_evaluator
1349  ); CHKERRQ(ierr);
1350 
1351 
1352  if(A) {
1353  ierr = MatAssemblyBegin(A,MAT_FINAL_ASSEMBLY); CHKERRQ(ierr);
1354  ierr = MatAssemblyEnd(A,MAT_FINAL_ASSEMBLY); CHKERRQ(ierr);
1355  }
1356 
1357  PetscFunctionReturn(0);
1358 }
CHKERRQ(ierr)
Finite element for approximating analytical filed on the mesh.

◆ save_data_on_mesh()

PetscErrorCode save_data_on_mesh ( MoFEM::Interface m_field,
const string &  problem_name,
const string &  re_field,
const string &  im_field,
Vec  D,
int  vt,
InsertMode  mode,
PetscBool  is_partitioned 
)

Definition at line 1360 of file AnalyticalSolutions.hpp.

1363  {
1364  PetscFunctionBegin;
1365 
1366  PetscErrorCode ierr;
1367  // save data on mesh
1369  /* set data to field from solution vec */
1370  if(is_partitioned) {
1371  ierr = m_field.set_local_ghost_vector(problem_name,COL,D,mode,SCATTER_REVERSE); CHKERRQ(ierr);
1372  } else {
1373  ierr = m_field.set_global_ghost_vector(problem_name,COL,D,mode,SCATTER_REVERSE); CHKERRQ(ierr);
1374  }
1375 
1376  } else {
1377 
1378  if(is_partitioned) {
1379  ierr = m_field.set_other_local_ghost_vector(problem_name,re_field,im_field,COL,D,mode,SCATTER_REVERSE); CHKERRQ(ierr);
1380  } else {
1381  ierr = m_field.set_other_global_ghost_vector(problem_name,re_field,im_field,COL,D,mode,SCATTER_REVERSE); CHKERRQ(ierr);
1382  }
1383 
1384  }
1385 
1386  PetscFunctionReturn(0);
1387 }
DEPRECATED MoFEMErrorCode set_global_ghost_vector(const Problem *problem_ptr, RowColData rc, Vec V, InsertMode mode, ScatterMode scatter_mode) const
set values of vector from/to mesh database (collective)collective - need tu be run on all processors ...
const double D
diffusivity
DEPRECATED MoFEMErrorCode set_local_ghost_vector(const Problem *problem_ptr, RowColData rc, Vec V, InsertMode mode, ScatterMode scatter_mode) const
set values of vector from/to meshdatabase
DEPRECATED MoFEMErrorCode set_other_global_ghost_vector(const Problem *problem_ptr, const std::string &field_name, const std::string &cpy_field_name, RowColData rc, Vec V, InsertMode mode, ScatterMode scatter_mode, int verb=-1)
Copy vector to field which is not part of the problem (collective)collective - need tu be run on all ...
DEPRECATED MoFEMErrorCode set_other_local_ghost_vector(const Problem *problem_ptr, const std::string &fiel_name, const std::string &cpy_field_name, RowColData rc, Vec V, InsertMode mode, ScatterMode scatter_mode, int verb=-1)
Copy vector to field which is not part of the problem.
CHKERRQ(ierr)

◆ solve_problem()

template<typename FUNEVAL >
PetscErrorCode solve_problem ( MoFEM::Interface m_field,
const string &  problem_name,
const string &  fe_name,
const string &  re_field,
const string &  im_field,
InsertMode  mode,
FUNEVAL &  fun_evaluator,
PetscBool  is_partitioned 
)
Examples
hcurl_check_approx_in_2d.cpp, prism_polynomial_approximation.cpp, quad_polynomial_approximation.cpp, and scalar_check_approximation_2d.cpp.

Definition at line 1390 of file AnalyticalSolutions.hpp.

1394  {
1395  PetscFunctionBegin;
1396 
1397  PetscErrorCode ierr;
1398 
1399  Mat A;
1400  ierr = m_field.MatCreateMPIAIJWithArrays(problem_name,&A); CHKERRQ(ierr);
1401  ierr = MatZeroEntries(A); CHKERRQ(ierr);
1402  Vec D;
1403 
1404  vector<Vec> vec_F;
1405  vec_F.resize(2);
1406 
1407  ierr = m_field.VecCreateGhost(problem_name,ROW,&vec_F[0]); CHKERRQ(ierr); /* real */
1408  ierr = m_field.VecCreateGhost(problem_name,ROW,&vec_F[1]); CHKERRQ(ierr); /* imag */
1409  ierr = m_field.VecCreateGhost(problem_name,COL,&D); CHKERRQ(ierr);
1410 
1411  for(int ss = 0;ss<2;ss++) {
1412  ierr = VecZeroEntries(vec_F[ss]); CHKERRQ(ierr);
1413  ierr = VecGhostUpdateBegin(vec_F[ss],INSERT_VALUES,SCATTER_FORWARD); CHKERRQ(ierr);
1414  ierr = VecGhostUpdateEnd(vec_F[ss],INSERT_VALUES,SCATTER_FORWARD); CHKERRQ(ierr);
1415  }
1416 
1417  ierr = calculate_matrix_and_vector(m_field,problem_name,fe_name,re_field,A,vec_F,fun_evaluator); CHKERRQ(ierr);
1418 
1419  KSP solver;
1420  ierr = KSPCreate(PETSC_COMM_WORLD,&solver); CHKERRQ(ierr);
1421  ierr = KSPSetOperators(solver,A,A); CHKERRQ(ierr);
1422  ierr = KSPSetFromOptions(solver); CHKERRQ(ierr);
1423  ierr = KSPSetUp(solver); CHKERRQ(ierr);
1424 
1425  for(int ss = 0;ss<GenericAnalyticalSolution::LAST_VAL_TYPE;ss++) {
1426  // solve problem
1427  ierr = KSPSolve(solver,vec_F[ss],D); CHKERRQ(ierr);
1428  ierr = VecGhostUpdateBegin(D,INSERT_VALUES,SCATTER_FORWARD); CHKERRQ(ierr);
1429  ierr = VecGhostUpdateEnd(D,INSERT_VALUES,SCATTER_FORWARD); CHKERRQ(ierr);
1430 
1431 
1432  ierr = save_data_on_mesh(m_field,problem_name,re_field,im_field,D,ss,mode,is_partitioned); CHKERRQ(ierr);
1433 
1434  }
1435 
1436  // clean
1437  ierr = KSPDestroy(&solver); CHKERRQ(ierr);
1438  ierr = VecDestroy(&vec_F[GenericAnalyticalSolution::REAL]); CHKERRQ(ierr);
1439  ierr = VecDestroy(&vec_F[GenericAnalyticalSolution::IMAG]); CHKERRQ(ierr);
1440 
1441  ierr = VecDestroy(&D); CHKERRQ(ierr);
1442  ierr = MatDestroy(&A); CHKERRQ(ierr);
1443 
1444  PetscFunctionReturn(0);
1445 }
const double D
diffusivity
PetscErrorCode save_data_on_mesh(MoFEM::Interface &m_field, const string &problem_name, const string &re_field, const string &im_field, Vec D, int vt, InsertMode mode, PetscBool is_partitioned)
PetscErrorCode calculate_matrix_and_vector(MoFEM::Interface &m_field, const string &problem_name, const string &fe_name, const string &re_field, Mat A, vector< Vec > vec_F, FUNVAL &fun_evaluator)
CHKERRQ(ierr)
DEPRECATED MoFEMErrorCode VecCreateGhost(const std::string &name, RowColData rc, Vec *V) const
create ghost vector for problem (collective)collective - need to be run on all processors in communic...
DEPRECATED MoFEMErrorCode MatCreateMPIAIJWithArrays(const std::string &name, Mat *Aij, int verb=DEFAULT_VERBOSITY)