38 m_dofsFactory (nullptr),
41 m_extraAdjacencyToSend ({}),
42 m_extraAdjacencyToRecv ({})
45 m_geometry = problem->getGeometry();
47 "Problem has no unknowns set ! Make sure to call defineUnknowns() of the problem class"
183 (*v)[dof->getGlobalIndex()] = func->operator()(args);
185 v->releaseLocalData();
192 return std::sqrt(pow(x[0]-y[0],2) + pow(x[1]-y[1],2) + pow(x[2]-y[2],2));
199 if (dof->getUnknown()==u)
201 CepsReal d = distanceToX(*dof->getVertex());
205 iMin = dof->getGlobalIndex();
229 sol->releaseLocalData();
243 DHVecPtr av (ceps::getNew<DistributedHaloVector>(*v));
244 DHVecPtr one(ceps::getNew<DistributedHaloVector>(*v));
247 return this->
dotProduct(one,av,boundary,attrs,unknowns);
258 return std::sqrt(this->
dotProduct(v,v,boundary,attrs,unknowns));
296 for (
auto [gid,setOfDofs]: locSlice)
297 for (
auto dof: setOfDofs)
298 if (dof->getOwner()==rank)
310 for (
auto [gid,setOfDofs]: locSlice)
312 for (
auto dof: setOfDofs)
356 auto dof = ceps::getNew<DegreeOfFreedom>(
393 or ui->getNumberOfAttributes()==0;
395 dof1->hasOneOfAttributes(ui->getAttributes()));
397 dof2->hasOneOfAttributes(ui->getAttributes()));
399 if (okAttributeI or (okAttribute1 and okAttribute2))
401 dof1->addNeighbor(dof2);
402 dof2->addNeighbor(dof1);
423 dNnz.resize(nLDofs,0U);
424 oNnz.resize(nLDofs,0U);
441 extraNgb.erase(ndofId);
445 if (not othersONnz[owner].
contains(ndofId))
446 othersONnz[owner][ndofId] = 1;
448 othersONnz[owner][ndofId]++;
456 dNnz[j] += 1+extraNgb.size();
471 if (not othersONnz[nOwner].
contains(nDofId))
472 othersONnz[nOwner][nDofId] = 1;
474 othersONnz[nOwner][nDofId]++;
485 for (
CepsProcId cpu1 = 0; cpu1<gridSize; cpu1++)
486 for (
CepsProcId cpu2 = 0; cpu2<gridSize; cpu2++)
489 if (cpu1!=cpu2 and (rank==cpu1 or rank==cpu2))
494 tmpMap = othersONnz[cpu2];
498 ceps::sendMap(cpu1,cpu2,tmpMap,gridSize*gridSize,cpu1*gridSize+cpu2);
501 for (
auto [row,nNz] : tmpMap)
534 haloIndices.push_back(dof->getGlobalIndex());
538 m_dofsFactory = ceps::getNew<DistributedFactory>(nDofs,nDofs,nLDofs,nLDofs,dNnz,oNnz);
557 hasUnknown = hasUnknown or u->getIdentifier()==uId;
574 resI.reserve(resSize);
577 resI.push_back(dof->getGlobalIndex());
580 resV.resize(resSize,0.);
582 vec->getValues(resV.data(),resSize,resI.data());
583 vec->releaseLocalData();
586 if (returnGeomIndices)
589 resI.reserve(resSize);
CepsArray< CepsMap< CepsGlobalIndex, CepsVector< DegreeOfFreedom * > >, CepsLocationFlagSize > DegreeOfFreedomTree
Data structure that classifies all the degrees of freedom.
CepsLocationFlag
DataLocation: an enum that will be used by various elements of the code (pde, readers,...
@ ZeroD
Data is defined once.
constexpr CepsUInt CepsLocationFlagSize
Size of enum CepsLocationFlag.
#define CEPS_ABORT_IF(condition, message)
Stops the execution with a message if condition is true. If testing is enabled, only throws a runtime...
CepsIndex CepsUnknownIndex
For unknowns.
std::map< _Key, _Tp, _Compare, _Alloc > CepsMap
C++ map.
CepsSize CepsHash
Hashes for distributed data.
std::set< _Type, _Compare, _Alloc > CepsSet
C++ set.
#define CEPS_MPI_GLOBAL_INDEX
std::vector< _Type, _Alloc > CepsVector
C++ vector.
size_t CepsSize
Size unsigned.
CepsGlobalIndex CepsDofGlobalIndex
Indices of degrees of freedom.
CepsIndex CepsGlobalIndex
Many uses. Has to be signed for PETSc.
std::make_unsigned_t< CepsInt > CepsUInt
Unsigned version on CepsInt.
float CepsReal
Need single precision floating point.
CepsUInt CepsProcId
For CPU indices.
CepsArray3< CepsReal > CepsReal3D
Three real scalars, used like this for compatibility in polynomials.
int32_t CepsInt
Need 32 bit integer.
constexpr CepsAttribute CepsUniversal
This attribute means "everywhere".
std::shared_ptr< DistributedHaloVector > DHVecPtr
Typedef for pointer on Distributed Halo CepsVector.
std::shared_ptr< DistributedMatrix > DMatPtr
Short typedef for pointer on dist matrix.
std::shared_ptr< DistributedVector > DVecPtr
Short typedef for pointer on distributed vector.
CepsStandardArgs getStandardArgsFrom(GeomCell *cell)
Returns a CepsStandardArgs structure with data from given cell.
DHVecPtr newDofHaloVector() const
Get a new vector from the factory, with halo data.
const DegreeOfFreedomTree & getDegreeOfFreedomTree() const
The sorted degrees of freedom.
void extractValuesForUnknownInternal(const CepsUnknownIndex &uId, DVecPtr vec, CepsVector< CepsIndex > &indices, CepsVector< CepsReal > &values, CepsBool sendToMaster, CepsBool returnGeomIndices, std::function< CepsBool(DegreeOfFreedom *)> &selector)
Slicing method that extracts the data corresponding to a specific unknown.
DistributedInfos< DegreeOfFreedom * > * getDistributedDofs() const
Get the stored Degree Of Freedom repartition.
AbstractPdeProblem * m_problem
[not owned] Pointer on the pde problem
const CepsMap< CepsUnknownIndex, CepsVector< DegreeOfFreedom * > > & getDegreesOfFreedomForUnknown()
Dofs sorted by unknown.
AbstractPdeProblem * getProblem() const
Return link to pde problem.
DistributedFactory * m_dofsFactory
[owned] The factory that builds vectors and matrices
virtual CepsReal dotProduct(DHVecPtr u, DHVecPtr v, CepsBool boundary=false, const CepsSet< CepsAttribute > &attrs={}, const CepsVector< Unknown * > &unknowns={})=0
Returns the dot product of two vectors of degrees of freedom.
void createDofsForZeroDUnknowns()
Adds one dof for each zeroD unknown, must be called after all other dofs are distributed.
void evaluateFunctionOnDofs(ceps::Function< CepsReal(CepsStandardArgs)> *func, DHVecPtr v, CepsReal t=0.) const
Fills vector v with values of function func at owned and halo dofs and time t.
CepsMap< CepsDofGlobalIndex, CepsSet< CepsDofGlobalIndex > > m_extraAdjacencyToRecv
A map to correct the missing adjacency that can occur in rare occasions in 3D.
~AbstractDiscretization() override
Destructor.
CepsBool m_dofsBuilt
Tells if the class has setup all the dofs.
AbstractDiscretization()=delete
Deleted default constructor.
CepsReal l1Norm(DHVecPtr v, CepsBool boundary=false, const CepsSet< CepsAttribute > &attrs={}, const CepsVector< Unknown * > &unknowns={})
L1-norm of a given vector.
CepsReal getZeroDValue(Unknown *u, DHVecPtr sol)
Get the value of a 0D unknown into a solution vector.
virtual void setZeroDUnknownsDofsInteractions()
Updates neighboring lists with interaction with 0D unknowns.
Geometry * getGeometry() const
Get the stored Geometry.
CepsMap< CepsUnknownIndex, CepsVector< DegreeOfFreedom * > > m_dofsForUnknown
Reverse mapping of dofs, with unknown index as key.
DVecPtr newDofVector() const
Get a new vector from the factory.
void buildDofsDistributedInfo()
Builds the degrees of freedom distribution from the dofs tree.
DistributedInfos< DegreeOfFreedom * > * m_distributedDofs
[owned] Pointer on the dofs structure
void findClosestDof(const CepsReal3D &x, Unknown *u, CepsDofGlobalIndex &dofId, CepsProcId &owner)
Set dofId to that if the closest to position x, also sets owner.
DistributedFactory * getDofsFactory() const
Get the stored DistributedFactory.
Geometry * m_geometry
[not owned] Pointer on the geometry
CepsReal l2Norm(DHVecPtr v, CepsBool boundary=false, const CepsSet< CepsAttribute > &attrs={}, const CepsVector< Unknown * > &unknowns={})
L2-norm of a given vector. Computation of dotproduct depends on the discretization.
DMatPtr newDofMatrix() const
Get a new matrix from the factory.
CepsLocationFlag m_spatialUnknownsLocation
Where unknowns are located. Must be set in child classes.
void setupDofsFactory()
Prepare the factory that will generate vectors of dofs.
CepsVector< DegreeOfFreedom * > getHaloDofs() const
Get the degrees of freedom owned by other processes.
virtual CepsIndex getDofSpatialId(const DegreeOfFreedom *dof) const =0
Return the spatial id (CellId or NodeId) for this row number.
DegreeOfFreedomTree m_dofsTree
[owned] Pointer on the distributed degree of freedom tree
virtual void setSpatialUnknownsDofsInteractions()=0
Build dofs neighboring list for spatial unknowns. Different in FE (same element dofs) and VF,...
virtual void buildDofsTree()=0
Builds the degrees of freedom tree from the PDE data.
CepsVector< DegreeOfFreedom * > getOwnedDofs() const
Get the degrees of freedom owned by process.
void buildDofs()
Builds the degrees of freedom data structures from the PDE data.
virtual void registerSpatialUnkown(Unknown *u)
Changes the location of unknown u to be adapted to the discrectization for example CepsLocationFlag::...
DegreeOfFreedom * getDof(CepsGlobalIndex globalDofId)
Get the dof with given globalID, nullptr if not found.
Base class for creating PDEs to solve.
const CepsVector< UnknownInteraction * > & getUnknownsInteractions() const
All the interactions between unknowns.
const CepsVector< Unknown * > & getUnknowns() const
List of unknowns of the pb.
Base class for other (big) CEPS classes. All classes can get a pointer to this base class and also co...
A degree of freedom for any kind of problem The dof can be associated to a geometrical element or not...
const CepsSet< DegreeOfFreedom * > & getNeighbors() const
Neighbor dofs.
void setHaloIndices(CepsIndex *haloRows, CepsUInt nHaloRows, CepsIndex *haloCols, CepsUInt nHaloCols)
Local halo rows and columns.
DVecPtr getDistributedVector() const
Pointer to created distributed vector.
DHVecPtr getDistributedHaloVector() const
Pointer on a created distributed vector that has additional memory allocated to enable the exchange o...
DMatPtr getDistributedMatrix() const
Pointer to created distributed matrix.
A class that manages data that is distributed between processors, not only real values (as in Distrib...
CepsUInt getGlobalIndexOffset(CepsProcId pId) const
Return the number of elements on the processes before pId This supposes that synchronizeTotalSize has...
CepsUInt getTotalNumberOfEntities() const
Total number of distributed data amongst all process.
const CepsVector< _Type > & getOwned() const
Get data owned by the processor, const.
LocalGlobalMapping< _Type, _Hash > * getHaloMapping()
Mapping between global and local index of halo data.
void add(const _Type &x, const _Hash &hashValue, const CepsGlobalIndex &globalId, const CepsUInt &pId)
Add entry with global ID to the container, hash must be provided, pId selects owned or halo.
void synchronize(CepsBool setGlobalIndicesFromLocals, std::function< void(_Type &, CepsGlobalIndex)> update=nullptr)
Recomputes global indices from all local indices, build correct halo global indices.
CepsUInt getNumberOfOwned() const
Number of owned data stored.
LocalGlobalMapping< _Type, _Hash > * getOwnedMapping()
Mapping between global and local index of owned data.
const CepsVector< _Type > & getHalo() const
Get halo data owned by neighbor processor, const.
Encapsulates all the geometrical data.
Data describing how two unknowns are coupled.
A class used to defined an unknown of a PDE problem The unknown can be defined on a specific region,...
CepsBool isSpatial() const
Tells if unknown is defined on geometrical elements.
void setLocation(const CepsLocationFlag &location)
Set the data location of the unknown.
CepsUnknownIndex getIdentifier() const
Get the identifier of the unknown.
CepsBool hasAttribute(const CepsAttribute &name) const
Tells if the entity has the attribute in argument.
const CepsGlobalIndex & getGlobalIndex() const
Get the index
const CepsProcId & getOwner() const
Get owner (processus id) of this entity.
constexpr CepsHash get(_Type const &i)
get a hash from a single value
CepsBool contains(const CepsVector< _Type, _Alloc > &vec, const _Type &item)
Tells if vectors contains a given item.
CepsUInt getRank()
Returns current processor rank.
MPI_Comm getCommunicator()
Get the communicator.
CepsUInt argmin(CepsVector< _Type, _Alloc > &vec)
Returns the position of the minimum in a whole vector.
const _Type & max(const CepsVector< _Type, _Alloc > &vec)
Returns the maximum of the vector, const version.
const _Type & min(const CepsVector< _Type, _Alloc > &vec)
Returns the minimum of the vector, const version.
int sendMap(const CepsUInt &sender, const CepsUInt &receiver, _Container< _Key, _Val > &table, const CepsUInt &nComms=1, const CepsUInt &commId=1)
send a map or mutlimap from a cpu to another
CepsUInt getGridSize()
Returns the number of process on the computing grid.
CepsBool isNullPtr(_Type *ptr)
Tells if passed pointer is null.
void barrier()
Explicit barrier: wait for all processors before continuing.
int allGatherv(const CepsVector< T > &localTab, int localSize, CepsVector< T > &globalTab, CepsBool masterOnly=false)
Gather all the local orig vector in the global dest vector.
void destroyObject(_Type &)
Destroy[delete] any type.
Structure used to pass arguments to SAFunc (see pde directory) The flags of the SAFunc allows extract...
function caller : abstract base, only contains an variadic operator()