Skip to content

Commit

Permalink
added documentation of GAUSS_SUBDIVIDED; added tag in quadAttribute; …
Browse files Browse the repository at this point in the history
…added Defaults.h
  • Loading branch information
Avirup Sircar committed Jan 26, 2024
1 parent d82ad8d commit 77de8fc
Show file tree
Hide file tree
Showing 8 changed files with 196 additions and 16 deletions.
3 changes: 2 additions & 1 deletion src/quadrature/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ set(DFT-EFE-QUADRATURE-SOURCES
QuadratureRuleAdaptive.cpp
QuadratureRuleGaussIterated.cpp
QuadratureValuesContainer.cpp
Integrate.cpp)
Integrate.cpp
Defaults.cpp)

add_library(dft-efe-quadrature SHARED ${DFT-EFE-QUADRATURE-SOURCES})

Expand Down
51 changes: 51 additions & 0 deletions src/quadrature/Defaults.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/******************************************************************************
* Copyright (c) 2021. *
* The Regents of the University of Michigan and DFT-EFE developers. *
* *
* This file is part of the DFT-EFE code. *
* *
* DFT-EFE is free software: you can redistribute it and/or modify *
* it under the terms of the Lesser GNU General Public License as *
* published by the Free Software Foundation, either version 3 of *
* the License, or (at your option) any later version. *
* *
* DFT-EFE is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the Lesser GNU General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License at the top level of DFT-EFE distribution. If not, see *
* <https://www.gnu.org/licenses/>. *
******************************************************************************/

/*
* @author Avirup Sircar
*/
#include <quadrature/Defaults.h>
#include <limits.h>

namespace dftefe
{
namespace quadrature
{
/**
* @brief Setting all the QuadratureRuleAdaptiveDefaults
*/
const double QuadratureRuleAdaptiveDefaults::SMALLEST_CELL_VOLUME = 1e-12;
const unsigned int QuadratureRuleAdaptiveDefaults::MAX_RECURSION = 1000;
/**
* @brief Setting all the QuadratureRuleAttributesDefaults
*/
const size_type QuadratureRuleAttributesDefaults::NUM_1D_POINTS = 0;
const std::string QuadratureRuleAttributesDefaults::TAG = std::string();

/**
* @brief Setting all the QuadratureRuleGaussSubdividedDefaults
*/
const size_type
QuadratureRuleGaussSubdividedDefaults::NUM_CELLS_FOR_ADAPTIVE_REFERENCE =
5;

} // end of namespace quadrature
} // end of namespace dftefe
79 changes: 79 additions & 0 deletions src/quadrature/Defaults.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/******************************************************************************
* Copyright (c) 2021. *
* The Regents of the University of Michigan and DFT-EFE developers. *
* *
* This file is part of the DFT-EFE code. *
* *
* DFT-EFE is free software: you can redistribute it and/or modify *
* it under the terms of the Lesser GNU General Public License as *
* published by the Free Software Foundation, either version 3 of *
* the License, or (at your option) any later version. *
* *
* DFT-EFE is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the Lesser GNU General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License at the top level of DFT-EFE distribution. If not, see *
* <https://www.gnu.org/licenses/>. *
******************************************************************************/

/*
* @author Avirup Sircar
*/

#ifndef dftefeQuadratureDefaults_h
#define dftefeQuadratureDefaults_h

#include <utils/TypeConfig.h>
#include <string>

namespace dftefe
{
namespace quadrature
{
class QuadratureRuleAdaptiveDefaults
{
public:
//
// smallest cell volume to recurse to
//
static const double SMALLEST_CELL_VOLUME;

//
// maximum recursion of divisions for adaptive quad
//
static const unsigned int MAX_RECURSION;

}; // end of class QuadratureRuleAdaptiveDefaults

class QuadratureRuleAttributesDefaults
{
public:
//
// default 1d points for checking isCartesianTensorStructured
//
static const size_type NUM_1D_POINTS;

//
// default string tag
//
static const std::string TAG;

}; // end of class QuadratureRuleAttributesDefaults

class QuadratureRuleGaussSubdividedDefaults
{
public:
//
// NUM_CELLS_FOR_ADAPTIVE_REFERENCE
//
static const size_type NUM_CELLS_FOR_ADAPTIVE_REFERENCE;

}; // end of class QuadratureRuleGaussSubdividedDefaults


} // end of namespace quadrature
} // end of namespace dftefe
#endif // dftefeQuadratureDefaults_h
13 changes: 11 additions & 2 deletions src/quadrature/QuadratureAttributes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,12 @@ namespace dftefe
QuadratureRuleAttributes::QuadratureRuleAttributes(
const QuadratureFamily quadratureFamily,
const bool isCartesianTensorStructured,
const size_type num1DPoints /*= 0*/)
const size_type num1DPoints /*= 0*/,
const std::string tag /*= std::string()*/)
: d_quadratureFamily(quadratureFamily)
, d_isCartesianTensorStructured(isCartesianTensorStructured)
, d_num1DPoints(num1DPoints)
, d_tag(tag)
{
if (d_isCartesianTensorStructured == false)
{
Expand Down Expand Up @@ -79,6 +81,12 @@ namespace dftefe
return d_num1DPoints;
}

std::string
QuadratureRuleAttributes::getTag() const
{
return d_tag;
}

bool
QuadratureRuleAttributes::operator==(
const QuadratureRuleAttributes &quadratureRuleAttributes) const
Expand All @@ -87,7 +95,8 @@ namespace dftefe
(d_quadratureFamily == quadratureRuleAttributes.d_quadratureFamily) &&
(d_num1DPoints == quadratureRuleAttributes.d_num1DPoints) &&
(d_isCartesianTensorStructured ==
quadratureRuleAttributes.d_isCartesianTensorStructured);
quadratureRuleAttributes.d_isCartesianTensorStructured) &&
(d_tag == quadratureRuleAttributes.d_tag);
return flag;
}
} // end of namespace quadrature
Expand Down
21 changes: 14 additions & 7 deletions src/quadrature/QuadratureAttributes.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@

#include <utils/TypeConfig.h>
#include <map>
#include <string>
#include <quadrature/Defaults.h>
namespace dftefe
{
namespace quadrature
Expand All @@ -43,10 +45,9 @@ namespace dftefe
// different cells have different Gauss-Legendre-Lobatto
// quadrature)
ADAPTIVE, // Adaptive quadrature rule
GAUSS_SUBDIVIDED // This family implies uniform Gauss quadrature rule in
// the domain The nGaussPoints in 1D is varied in each
// domain and the maximum of the points is taken as the
// gauss quad rule.
GAUSS_SUBDIVIDED // This family implies gauss iterated and but in an
// optimal manner where the {order, copy} pair is
// determined from an algorithm.
};

enum class QuadratureRuleType
Expand Down Expand Up @@ -134,16 +135,21 @@ namespace dftefe
{
public:
QuadratureRuleAttributes();
QuadratureRuleAttributes(const QuadratureFamily quadratureFamily,
const bool isCartesianTensorStructured,
const size_type num1DPoints = 0);
QuadratureRuleAttributes(
const QuadratureFamily quadratureFamily,
const bool isCartesianTensorStructured,
const size_type num1DPoints =
QuadratureRuleAttributesDefaults::NUM_1D_POINTS,
const std::string tag = QuadratureRuleAttributesDefaults::TAG);
~QuadratureRuleAttributes() = default;
QuadratureFamily
getQuadratureFamily() const;
bool
isCartesianTensorStructured() const;
size_type
getNum1DPoints() const;
std::string
getTag() const;

bool
operator==(
Expand All @@ -153,6 +159,7 @@ namespace dftefe
QuadratureFamily d_quadratureFamily;
bool d_isCartesianTensorStructured;
size_type d_num1DPoints;
std::string d_tag;
}; // end of QuadratureRuleAttributes

/**
Expand Down
7 changes: 5 additions & 2 deletions src/quadrature/QuadratureRuleAdaptive.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <basis/ParentToChildCellsManagerBase.h>
#include <vector>
#include <memory>
#include <quadrature/Defaults.h>

namespace dftefe
{
Expand All @@ -27,8 +28,10 @@ namespace dftefe
const std::vector<double> &absoluteTolerances,
const std::vector<double> &relativeTolerances,
const std::vector<double> &integralThresholds,
const double smallestCellVolume = 1e-12,
const unsigned int maxRecursion = 100);
const double smallestCellVolume =
QuadratureRuleAdaptiveDefaults::SMALLEST_CELL_VOLUME,
const unsigned int maxRecursion =
QuadratureRuleAdaptiveDefaults::MAX_RECURSION);

private:
};
Expand Down
7 changes: 4 additions & 3 deletions src/quadrature/QuadratureRuleContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,7 @@ namespace dftefe
const QuadratureFamily quadFamily =
d_quadratureRuleAttributes.getQuadratureFamily();
if (!(quadFamily == QuadratureFamily::GAUSS ||
quadFamily == QuadratureFamily::GLL ||
quadFamily == QuadratureFamily::GAUSS_SUBDIVIDED))
quadFamily == QuadratureFamily::GLL))
utils::throwException<utils::LogicError>(
false,
"The constructor "
Expand Down Expand Up @@ -323,7 +322,9 @@ namespace dftefe
if (quadratureRuleContainerReference.getQuadratureRuleAttributes()
.getQuadratureFamily() == QuadratureFamily::ADAPTIVE)
{
const size_type numCellsInSet = 5;
const size_type numCellsInSet =
QuadratureRuleGaussSubdividedDefaults::
NUM_CELLS_FOR_ADAPTIVE_REFERENCE;
std::vector<double> referenceQuadDensityInCellsVec(0);
std::vector<size_type> cellIndex(numCells, 0);

Expand Down
31 changes: 30 additions & 1 deletion src/quadrature/QuadratureRuleContainer.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include <memory>
#include <utils/MPITypes.h>
#include <utils/MPIWrapper.h>

#include <quadrature/Defaults.h>
namespace dftefe
{
namespace quadrature
Expand Down Expand Up @@ -83,6 +83,35 @@ namespace dftefe
const double smallestCellVolume = 1e-12,
const unsigned int maxRecursion = 100);

/**
* @brief Constructor for creating a subdivided quadrature rule in each cell based
* user-defined functions and a reference quadrature. So one provides a
* minimum and maximum order (or number of 1D gauss points) and maimum
* number of copies of the orders one wants to go. Also one has a
* reference quadrature which can
* 1. either be constructed from highly refined tensor structures of GAUSS
* or GLL. from spatally variable quadrature rules like GAUSS_VARIABLE,
* GLL_VARIABLE, or ADAPTIVE. Care should be taken that for ADAPTIVE it is
* assumed that the quadrature is optimal and hence only cells with high
* quadrature density are traversed. Whereas for all others all the cells
* are traversed. Then the {order, copy} pair with minimum quad points per
* cell is chosen. Then again the maximum of this points over all
* processors are taken. In one statement the condition can be written as
* sup_{processors} inf_{all pairs in a processor} (QuadPoints in Cells
* statisfing the given tolerances w.r.t. the reference quadrature)
* @param[in] order1DMin The minimum gauss 1D number of points from which
* to start
* @param[in] order1DMax The maximum gauss 1D number of points upto which
* to iterate
* @param[in] copies1DMax The maimum number of copies (starting from 1) to
* be done at each iteration of order.
* @param[in] triangulation The triangulation that has information on the
* cell and its vertices
* @param[in] cellMapping cellMapping object that provides the the
* information on how the cell in real space is mapped to its parametric
* coordinates. This is required to calculate the JxW values at each quad
* point
*/
QuadratureRuleContainer(
const QuadratureRuleAttributes &quadratureRuleAttributes,
const size_type order1DMin,
Expand Down

0 comments on commit 77de8fc

Please sign in to comment.