| 1 |
/* |
| 2 |
* Advanced Simulation Library <http://asl.org.il> |
| 3 |
* |
| 4 |
* Copyright 2015 Avtech Scientific <http://avtechscientific.com> |
| 5 |
* |
| 6 |
* |
| 7 |
* This file is part of Advanced Simulation Library (ASL). |
| 8 |
* |
| 9 |
* ASL is free software: you can redistribute it and/or modify it |
| 10 |
* under the terms of the GNU Affero General Public License as |
| 11 |
* published by the Free Software Foundation, version 3 of the License. |
| 12 |
* |
| 13 |
* ASL is distributed in the hope that it will be useful, |
| 14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 |
* GNU Affero General Public License for more details. |
| 17 |
* |
| 18 |
* You should have received a copy of the GNU Affero General Public License |
| 19 |
* along with ASL. If not, see <http://www.gnu.org/licenses/>. |
| 20 |
* |
| 21 |
*/ |
| 22 |
|
| 23 |
|
| 24 |
#ifndef ASLBCOND_H |
| 25 |
#define ASLBCOND_H |
| 26 |
|
| 27 |
#include "aslNumMethod.h" |
| 28 |
#include <data/aslBlocks.h> |
| 29 |
#include <acl/aclMath/aclVectorOfElementsDef.h> |
| 30 |
|
| 31 |
|
| 32 |
namespace acl |
| 33 |
{ |
| 34 |
class ExpressionContainer; |
| 35 |
} |
| 36 |
|
| 37 |
namespace asl |
| 38 |
{ |
| 39 |
|
| 40 |
class VectorTemplate; |
| 41 |
template <typename V> class DataWithGhostNodes; |
| 42 |
typedef DataWithGhostNodes<acl::VectorOfElementsData> DataWithGhostNodesACLData; |
| 43 |
typedef std::shared_ptr<DataWithGhostNodesACLData> SPDataWithGhostNodesACLData; |
| 44 |
typedef DataWithGhostNodes<acl::VectorOfElements> DataWithGhostNodesACL; |
| 45 |
typedef std::shared_ptr<DataWithGhostNodesACL> SPDataWithGhostNodesACL; |
| 46 |
class TemplateVE; |
| 47 |
class DistanceFunction; |
| 48 |
typedef std::shared_ptr<DistanceFunction> SPDistanceFunction; |
| 49 |
|
| 50 |
|
| 51 |
class AbstractDataWithGhostNodes; |
| 52 |
typedef std::shared_ptr<AbstractDataWithGhostNodes> SPAbstractDataWithGhostNodes; |
| 53 |
|
| 54 |
/// Virtual class describes general interface for boundary conditions |
| 55 |
/** |
| 56 |
\ingroup BoundaryConditions |
| 57 |
*/ |
| 58 |
class BCond: public NumMethod |
| 59 |
{ |
| 60 |
protected: |
| 61 |
Block block; |
| 62 |
const VectorTemplate * const templ; |
| 63 |
|
| 64 |
std::vector<int> indices; |
| 65 |
std::vector<int> directions; |
| 66 |
std::vector<double> fractions; |
| 67 |
std::vector<int> neighbourIndices; |
| 68 |
|
| 69 |
acl::SPVectorOfElementsData indicesACL; |
| 70 |
acl::SPVectorOfElementsData neighbourIndicesACL; |
| 71 |
acl::SPVectorOfElementsData directionsACL; |
| 72 |
acl::SPVectorOfElementsData fractionsACL; |
| 73 |
|
| 74 |
void loadIndicesToACL(); |
| 75 |
void loadNeighbourIndicesToACL(); |
| 76 |
void loadDirectionsToACL(); |
| 77 |
void loadfractionsACL(); |
| 78 |
|
| 79 |
public: |
| 80 |
BCond(const Block & b); |
| 81 |
BCond(const Block & b, const VectorTemplate * const t); |
| 82 |
void addPoint(AVec<int> a,int d=0,double fr=0); |
| 83 |
const Block & getBlock(); |
| 84 |
inline const VectorTemplate * getVT(); |
| 85 |
|
| 86 |
}; |
| 87 |
|
| 88 |
typedef std::shared_ptr<BCond> SPBCond; |
| 89 |
|
| 90 |
/// Virtual class describes general interface for boundary conditions |
| 91 |
/** |
| 92 |
\ingroup BoundaryConditions |
| 93 |
|
| 94 |
The class is aimed to deal with numerical with computational map. Namely |
| 95 |
it should be a DataWithGhestNodes object with values in each point |
| 96 |
which can be interpreted as a computation map. The inteprretation law is: |
| 97 |
- computation region: \f$ map(\vec r) > 0 \f$ |
| 98 |
- outside region: \f$ map(\vec r) \leq 0 \f$ |
| 99 |
*/ |
| 100 |
class BCondWithMap:public NumMethod |
| 101 |
{ |
| 102 |
protected: |
| 103 |
/// flag whether the point list to be generated or not |
| 104 |
bool pointsListFlag; |
| 105 |
acl::VectorOfElements currentPoint; |
| 106 |
const VectorTemplate * const templ; |
| 107 |
|
| 108 |
/// block |
| 109 |
Block bl; |
| 110 |
/// boundary description for the particular BC |
| 111 |
SPAbstractDataWithGhostNodes map; |
| 112 |
SPDistanceFunction mapDF; |
| 113 |
/// Computational domain which contains all boundaries and the particular boundary as well |
| 114 |
SPAbstractDataWithGhostNodes computationalDomain; |
| 115 |
SPDistanceFunction computationalDomainDF; |
| 116 |
|
| 117 |
unique_ptr<TemplateVE> mapTVE; |
| 118 |
unique_ptr<TemplateVE> cDomainTVE; |
| 119 |
|
| 120 |
/// initialize mapTVE and cDomainTVE |
| 121 |
virtual void initMapInfrastructure(acl::ExpressionContainer & ec); |
| 122 |
/// returns expression corresponding to check if the node in i^th direction is ghost one |
| 123 |
/** |
| 124 |
Requires call of initMapInfrastructure |
| 125 |
*/ |
| 126 |
acl::VectorOfElements isGhostNode(unsigned int i); |
| 127 |
/// returns expression corresponding to check if the node in i^th direction is computation one |
| 128 |
/** |
| 129 |
Requires call of initMapInfrastructure |
| 130 |
*/ |
| 131 |
acl::VectorOfElements isComputationNode(unsigned int i); |
| 132 |
/// returns expression corresponding to check if nodes in directions \p ii are computation ones |
| 133 |
/** |
| 134 |
Requires call of initMapInfrastructure |
| 135 |
*/ |
| 136 |
acl::VectorOfElements isComputationNode(const vector<unsigned int> & ii); |
| 137 |
/// returns expression corresponding to check if the current node is ghost one |
| 138 |
acl::VectorOfElements isGhostNode(); |
| 139 |
/// returns expression corresponding to check if the current node is computation one |
| 140 |
acl::VectorOfElements isComputationNode(); |
| 141 |
|
| 142 |
/** |
| 143 |
\param m the map |
| 144 |
\param t the corresponding template |
| 145 |
*/ |
| 146 |
BCondWithMap(SPAbstractDataWithGhostNodes m, const VectorTemplate * const vt); |
| 147 |
/** |
| 148 |
\param m the map |
| 149 |
\param t the corresponding template |
| 150 |
*/ |
| 151 |
BCondWithMap(SPDistanceFunction m, const Block & b, const VectorTemplate * const vt); |
| 152 |
/** |
| 153 |
\param m the map for the particular boundary |
| 154 |
\param cd the map for the computational domain |
| 155 |
\param t the corresponding template |
| 156 |
*/ |
| 157 |
BCondWithMap(SPAbstractDataWithGhostNodes m, |
| 158 |
SPAbstractDataWithGhostNodes cd, |
| 159 |
const VectorTemplate * const vt); |
| 160 |
/** |
| 161 |
\param m the map for the particular boundary |
| 162 |
\param cd the map for the computational domain |
| 163 |
\param t the corresponding template |
| 164 |
*/ |
| 165 |
BCondWithMap(SPAbstractDataWithGhostNodes m, |
| 166 |
SPDistanceFunction cd, |
| 167 |
const VectorTemplate * const vt); |
| 168 |
/** |
| 169 |
\param m the map for the particular boundary |
| 170 |
\param cd the map for the computational domain |
| 171 |
\param t the corresponding template |
| 172 |
\param b the computation block |
| 173 |
*/ |
| 174 |
BCondWithMap(SPDistanceFunction m, |
| 175 |
SPDistanceFunction cd, |
| 176 |
const Block & b, |
| 177 |
const VectorTemplate * const vt); |
| 178 |
public: |
| 179 |
inline const VectorTemplate * getVT(); |
| 180 |
}; |
| 181 |
|
| 182 |
|
| 183 |
/// Virtual class describes general interface for boundary conditions which connect two datas |
| 184 |
/** |
| 185 |
\ingroup BoundaryConditions |
| 186 |
The class contains an explicit list of coneting points. |
| 187 |
This gives certain flexibility for definition of the boundary geometry. |
| 188 |
*/ |
| 189 |
class BCondConnector:public NumMethod |
| 190 |
{ |
| 191 |
protected: |
| 192 |
Block block1; |
| 193 |
Block block2; |
| 194 |
|
| 195 |
std::vector<int> indices1; |
| 196 |
std::vector<int> directions1; |
| 197 |
std::vector<int> indices2; |
| 198 |
std::vector<int> directions2; |
| 199 |
|
| 200 |
acl::SPVectorOfElementsData indices1ACL; |
| 201 |
acl::SPVectorOfElementsData directions1ACL; |
| 202 |
acl::SPVectorOfElementsData indices2ACL; |
| 203 |
acl::SPVectorOfElementsData directions2ACL; |
| 204 |
|
| 205 |
void loadIndicesToACL(); |
| 206 |
void loadDirectionsToACL(); |
| 207 |
public: |
| 208 |
BCondConnector(const Block & b1, const Block & b2); |
| 209 |
void addGhostPoint(AVec<int> a1,AVec<int> a2); |
| 210 |
void addGhostPoint(AVec<int> a1,int d1,AVec<int> a2,int d2); |
| 211 |
const Block & getBlock1(); |
| 212 |
const Block & getBlock2(); |
| 213 |
}; |
| 214 |
|
| 215 |
|
| 216 |
/// Virtual class describes general interface for boundary conditions |
| 217 |
/** |
| 218 |
\ingroup BoundaryConditions |
| 219 |
|
| 220 |
The class differs from the class BCond by no use of the |
| 221 |
explicite connection point lists. The boundary slice defined by first and last |
| 222 |
points. |
| 223 |
|
| 224 |
\todo Add posibility to define several slices with different |
| 225 |
dimensionalities |
| 226 |
*/ |
| 227 |
class BCondSlice:public NumMethod |
| 228 |
{ |
| 229 |
protected: |
| 230 |
Block block; |
| 231 |
const VectorTemplate * const templ; |
| 232 |
|
| 233 |
int pointB; |
| 234 |
int pointE; |
| 235 |
AVec<int> sliceDimentions; |
| 236 |
AVec<int> sliceIncrements; |
| 237 |
int direction; |
| 238 |
|
| 239 |
public: |
| 240 |
BCondSlice(const Block & b); |
| 241 |
BCondSlice(const Block & b, const VectorTemplate * const t); |
| 242 |
void addGhostSlice(AVec<int> pB,AVec<int> pE, int dir); |
| 243 |
const Block & getBlock(); |
| 244 |
}; |
| 245 |
|
| 246 |
/// Virtual class describes general interface for boundary conditions which connect two datas |
| 247 |
/** |
| 248 |
\ingroup BoundaryConditions |
| 249 |
|
| 250 |
The class differs from the class BCondConnector by no use of the |
| 251 |
explicite connection point lists. The boundary defined by fist and last |
| 252 |
point numbers and by definition of corresponding increments and |
| 253 |
dimensionality of the point set. |
| 254 |
|
| 255 |
\todo Add posibility to define several slices with different |
| 256 |
dimensionalities |
| 257 |
*/ |
| 258 |
class BCondConnectorSlice:public NumMethod |
| 259 |
{ |
| 260 |
protected: |
| 261 |
Block block1; |
| 262 |
Block block2; |
| 263 |
const VectorTemplate * const templ; |
| 264 |
|
| 265 |
int point1B; |
| 266 |
int point1E; |
| 267 |
AVec<int> sliceDimentions1; |
| 268 |
AVec<int> sliceIncrements1; |
| 269 |
int direction1; |
| 270 |
|
| 271 |
int point2B; |
| 272 |
int point2E; |
| 273 |
AVec<int> sliceDimentions2; |
| 274 |
AVec<int> sliceIncrements2; |
| 275 |
int direction2; |
| 276 |
|
| 277 |
public: |
| 278 |
BCondConnectorSlice(const Block & b1, const Block & b2, const VectorTemplate *const t); |
| 279 |
void addGhostSlice1(AVec<int> pB,AVec<int> pE, int dir); |
| 280 |
void addGhostSlice2(AVec<int> pB,AVec<int> pE, int dir); |
| 281 |
const Block & getBlock1(); |
| 282 |
const Block & getBlock2(); |
| 283 |
}; |
| 284 |
|
| 285 |
/// Virtual class describes general interface for boundary conditions |
| 286 |
/** |
| 287 |
The class is sutable for BC with moving boundary. It takes the |
| 288 |
list points and corresponding normals as an input. The boundary conditions |
| 289 |
are computed automaticaly for a given VectorTemplate. |
| 290 |
\ingroup BoundaryConditions |
| 291 |
*/ |
| 292 |
class BCondDynamic:public NumMethod |
| 293 |
{ |
| 294 |
protected: |
| 295 |
Block block; |
| 296 |
const VectorTemplate * const templ; |
| 297 |
|
| 298 |
acl::SPVectorOfElementsData pointsACL; |
| 299 |
acl::SPVectorOfElementsData normalsACL; |
| 300 |
|
| 301 |
public: |
| 302 |
BCondDynamic(const Block & b); |
| 303 |
BCondDynamic(const Block & b, const VectorTemplate * const t); |
| 304 |
const Block & getBlock(); |
| 305 |
inline const VectorTemplate * getVT(); |
| 306 |
}; |
| 307 |
|
| 308 |
/// defines names of walls of a box \ingroup BoundaryConditions |
| 309 |
enum SlicesNames {X0, XE, Y0, YE, Z0, ZE}; |
| 310 |
|
| 311 |
/// \ingroup BoundaryConditions |
| 312 |
///@{ |
| 313 |
void addSliceX0(BCond &); |
| 314 |
void addSliceXE(BCond &); |
| 315 |
void addSliceY0(BCond &); |
| 316 |
void addSliceYE(BCond &); |
| 317 |
void addSliceZ0(BCond &); |
| 318 |
void addSliceZE(BCond &); |
| 319 |
///@} |
| 320 |
|
| 321 |
void addSlices(BCond &, const vector<SlicesNames> &); |
| 322 |
|
| 323 |
///adds slice only points without directions \ingroup BoundaryConditions |
| 324 |
///@{ |
| 325 |
void addSliceX(BCond &, int x); |
| 326 |
void addSliceY(BCond &, int y); |
| 327 |
void addSliceZ(BCond &, int z); |
| 328 |
///@} |
| 329 |
|
| 330 |
/// \ingroup BoundaryConditions |
| 331 |
///@{ |
| 332 |
void addSliceX0(BCondSlice &); |
| 333 |
void addSliceXE(BCondSlice &); |
| 334 |
void addSliceY0(BCondSlice &); |
| 335 |
void addSliceYE(BCondSlice &); |
| 336 |
void addSliceZ0(BCondSlice &); |
| 337 |
void addSliceZE(BCondSlice &); |
| 338 |
///@} |
| 339 |
|
| 340 |
// --------------------------- Implementation ---------------------- |
| 341 |
inline const VectorTemplate * BCond::getVT() |
| 342 |
{ |
| 343 |
return templ; |
| 344 |
} |
| 345 |
|
| 346 |
inline const VectorTemplate * BCondWithMap::getVT() |
| 347 |
{ |
| 348 |
return templ; |
| 349 |
} |
| 350 |
|
| 351 |
} |
| 352 |
|
| 353 |
#endif //ASLBCOND_H |