22template<
typename ValueType>
25 LaplacianOperatorFactory<ValueType>,
26 Parameters<const Executor&, const UnstructuredMesh&, const Input&>>
31 static std::unique_ptr<LaplacianOperatorFactory<ValueType>>
34 std::string key = (std::holds_alternative<Dictionary>(inputs))
35 ? std::get<Dictionary>(inputs).get<std::string>(
"LaplacianOperator")
36 : std::get<TokenList>(inputs).next<std::string>();
41 static std::string
name() {
return "LaplacianOperatorFactory"; }
76 virtual std::unique_ptr<LaplacianOperatorFactory<ValueType>>
clone()
const = 0;
89template<
typename ValueType>
102 gamma_(lapOp.gamma_),
103 laplacianOperatorStrategy_(
104 lapOp.laplacianOperatorStrategy_ ? lapOp.laplacianOperatorStrategy_->clone() : nullptr
115 laplacianOperatorStrategy_(
126 gamma_(gamma), laplacianOperatorStrategy_(std::move(laplacianOperatorStrategy)) {};
132 gamma_(gamma), laplacianOperatorStrategy_(nullptr) {};
137 NF_ASSERT(laplacianOperatorStrategy_,
"LaplacianOperatorStrategy not initialized");
140 laplacianOperatorStrategy_->laplacian(tmpsource, gamma_, this->
field_, operatorScaling);
146 NF_ASSERT(laplacianOperatorStrategy_,
"LaplacianOperatorStrategy not initialized");
148 laplacianOperatorStrategy_->laplacian(ls, gamma_, this->
field_, operatorScaling);
164 laplacianOperatorStrategy_->laplacian(lapPhi, gamma_, this->
getVector(), operatorScaling);
170 std::string
name =
"laplacian(" + gamma_.
name +
"," + this->
field_.name +
")";
177 laplacianOperatorStrategy_->laplacian(lapPhi, gamma_, this->
field_, operatorScaling);
184 if (std::holds_alternative<NeoN::Dictionary>(input))
186 auto dict = std::get<NeoN::Dictionary>(input);
187 std::string schemeName =
"laplacian(" + gamma_.
name +
"," + this->
field_.name +
")";
188 auto tokens = dict.subDict(
"laplacianSchemes").get<
NeoN::TokenList>(schemeName);
189 laplacianOperatorStrategy_ =
194 auto tokens = std::get<NeoN::TokenList>(input);
195 laplacianOperatorStrategy_ =
200 std::string
getName()
const {
return "LaplacianOperator"; }
206 std::unique_ptr<LaplacianOperatorFactory<ValueType>> laplacianOperatorStrategy_;
A factory class for runtime selection of derived classes.
A class representing a list of tokens.
Represents an unstructured mesh in NeoN.
A class to contain the data and executors for a field and define some basic operations.
A class that represents a coefficient for the NeoN dsl.
VolumeField< ValueType > & getVector()
const Executor exec_
Executor associated with the field. (CPU, GPU, openMP, etc.)
OperatorMixin(const Executor exec, const Coeff &coeffs, VolumeField< ValueType > &field, Operator::Type type)
VolumeField< ValueType > & field_
virtual const Executor & exec() const final
static std::unique_ptr< LaplacianOperatorFactory< ValueType > > create(const Executor &exec, const UnstructuredMesh &mesh, const Input &inputs)
virtual void laplacian(Vector< ValueType > &lapPhi, const SurfaceField< scalar > &gamma, VolumeField< ValueType > &phi, const dsl::Coeff operatorScaling)=0
virtual std::unique_ptr< LaplacianOperatorFactory< ValueType > > clone() const =0
virtual void laplacian(VolumeField< ValueType > &lapPhi, const SurfaceField< scalar > &gamma, VolumeField< ValueType > &phi, const dsl::Coeff operatorScaling)=0
virtual void laplacian(la::LinearSystem< ValueType, localIdx > &ls, const SurfaceField< scalar > &gamma, VolumeField< ValueType > &phi, const dsl::Coeff operatorScaling)=0
const UnstructuredMesh & mesh_
LaplacianOperatorFactory(const Executor &exec, const UnstructuredMesh &mesh)
const la::SparsityPattern & getSparsityPattern() const
static std::string name()
virtual VolumeField< ValueType > laplacian(const SurfaceField< scalar > &gamma, VolumeField< ValueType > &phi, const dsl::Coeff operatorScaling) const =0
virtual ~LaplacianOperatorFactory()
const la::SparsityPattern & sparsityPattern_
void laplacian(VolumeField< scalar > &lapPhi)
LaplacianOperator(dsl::Operator::Type termType, const SurfaceField< scalar > &gamma, VolumeField< ValueType > &phi, std::unique_ptr< LaplacianOperatorFactory< ValueType > > laplacianOperatorStrategy)
void implicitOperation(la::LinearSystem< ValueType, localIdx > &ls) const
std::string getName() const
LaplacianOperator(const LaplacianOperator &lapOp)
LaplacianOperator(dsl::Operator::Type termType, const SurfaceField< scalar > &gamma, VolumeField< ValueType > &phi)
void read(const Input &input)
void explicitOperation(Vector< ValueType > &source) const
VolumeField< scalar > laplacian()
ValueType VectorValueType
LaplacianOperator(dsl::Operator::Type termType, const SurfaceField< scalar > &gamma, VolumeField< ValueType > &phi, Input input)
Represents a surface field in a finite volume method.
Represents a volume boundary field for a cell-centered finite volume method.
Represents a volume field in a finite volume method.
A class representing a linear system of equations.
#define NF_ASSERT(condition, message)
Macro for asserting a condition and printing an error message if the condition is false.
std::vector< BoundaryType > createCalculatedBCs(const UnstructuredMesh &mesh)
std::variant< Dictionary, TokenList > Input
std::variant< SerialExecutor, CPUExecutor, GPUExecutor > Executor
const std::string & name(const NeoN::Document &doc)
Retrieves the name of a Document.