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;
85template<
typename ValueType>
99 laplacianOperatorStrategy_(
100 lapOp.laplacianOperatorStrategy_ ? lapOp.laplacianOperatorStrategy_->clone() : nullptr
111 laplacianOperatorStrategy_(
122 gamma_(gamma), laplacianOperatorStrategy_(std::move(laplacianOperatorStrategy)) {};
128 gamma_(gamma), laplacianOperatorStrategy_(nullptr) {};
133 NF_ASSERT(laplacianOperatorStrategy_,
"LaplacianOperatorStrategy not initialized");
136 laplacianOperatorStrategy_->laplacian(tmpsource, gamma_, this->
field_, operatorScaling);
142 NF_ASSERT(laplacianOperatorStrategy_,
"LaplacianOperatorStrategy not initialized");
144 laplacianOperatorStrategy_->laplacian(ls, gamma_, this->
field_, operatorScaling);
160 laplacianOperatorStrategy_->laplacian(lapPhi, gamma_, this->
getVector(), operatorScaling);
166 std::string
name =
"laplacian(" + gamma_.
name +
"," + this->
field_.name +
")";
173 laplacianOperatorStrategy_->laplacian(lapPhi, gamma_, this->
field_, operatorScaling);
180 if (std::holds_alternative<NeoN::Dictionary>(input))
182 auto dict = std::get<NeoN::Dictionary>(input);
183 std::string schemeName =
"laplacian(" + gamma_.
name +
"," + this->
field_.name +
")";
184 auto tokens = dict.subDict(
"laplacianSchemes").get<
NeoN::TokenList>(schemeName);
185 laplacianOperatorStrategy_ =
190 auto tokens = std::get<NeoN::TokenList>(input);
191 laplacianOperatorStrategy_ =
196 std::string
getName()
const {
return "LaplacianOperator"; }
202 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
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
static std::unique_ptr< LaplacianOperatorFactory< ValueType > > create(const Executor &exec, const UnstructuredMesh &uMesh, const Input &inputs)
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)
static std::string name()
virtual VolumeField< ValueType > laplacian(const SurfaceField< scalar > &gamma, VolumeField< ValueType > &phi, const dsl::Coeff operatorScaling) const =0
virtual ~LaplacianOperatorFactory()
void laplacian(VolumeField< scalar > &lapPhi)
void build(const Input &input)
LaplacianOperator(dsl::Operator::Type termType, const SurfaceField< scalar > &gamma, VolumeField< ValueType > &phi, std::unique_ptr< LaplacianOperatorFactory< ValueType > > laplacianOperatorStrategy)
std::string getName() const
LaplacianOperator(const LaplacianOperator &lapOp)
LaplacianOperator(dsl::Operator::Type termType, const SurfaceField< scalar > &gamma, VolumeField< ValueType > &phi)
void explicitOperation(Vector< ValueType > &source) const
VolumeField< scalar > laplacian()
ValueType VectorValueType
void implicitOperation(la::LinearSystem< ValueType, localIdx > &ls)
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.